@eagleoutice/flowr 2.13.16 → 2.14.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 +36 -25
- package/abstract-interpretation/absint-visitor.js +1 -1
- package/abstract-interpretation/data-frame/mappers/access-mapper.js +4 -4
- package/abstract-interpretation/data-frame/mappers/arguments.js +7 -4
- package/abstract-interpretation/data-frame/mappers/function-mapper.js +18 -17
- package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +6 -6
- package/abstract-interpretation/data-frame/resolve-args.d.ts +9 -4
- package/abstract-interpretation/data-frame/resolve-args.js +10 -5
- package/benchmark/calibration.d.ts +16 -7
- package/benchmark/calibration.js +44 -17
- package/benchmark/slicer.d.ts +3 -2
- package/benchmark/slicer.js +9 -5
- package/benchmark/stats/size-of.js +1 -1
- package/benchmark/summarizer/first-phase/process.d.ts +2 -0
- package/benchmark/summarizer/first-phase/process.js +2 -0
- package/cli/benchmark-app.js +4 -1
- package/cli/benchmark-helper-app.d.ts +1 -0
- package/cli/benchmark-helper-app.js +2 -2
- package/cli/common/options.d.ts +5 -31
- package/cli/common/options.js +2 -8
- package/cli/common/scripts-info.d.ts +5 -38
- package/cli/common/scripts-info.js +0 -8
- package/cli/repl/core.js +1 -1
- package/cli/repl/execute.d.ts +2 -2
- package/cli/repl/execute.js +2 -2
- package/cli/repl/parser/slice-query-parser.js +1 -1
- package/cli/repl/print-version.js +2 -2
- package/config.d.ts +16 -0
- package/config.js +83 -5
- package/control-flow/extract-cfg.js +1 -1
- package/control-flow/semantic-cfg-guided-visitor.d.ts +1 -1
- package/control-flow/semantic-cfg-guided-visitor.js +1 -1
- package/control-flow/useless-loop.js +1 -1
- package/core/print/slice-diff-ansi.js +1 -1
- package/core/steps/pipeline/create-pipeline.js +1 -1
- package/dataflow/cluster.js +2 -2
- package/dataflow/environments/apply-kill.js +1 -1
- package/dataflow/environments/built-in-props.d.ts +13 -2
- package/dataflow/environments/built-in-props.js +23 -1
- package/dataflow/environments/built-in.d.ts +7 -1
- package/dataflow/environments/built-in.js +42 -3
- package/dataflow/environments/default-builtin-config.d.ts +518 -11
- package/dataflow/environments/default-builtin-config.js +218 -23
- package/dataflow/environments/environment.d.ts +10 -2
- package/dataflow/environments/environment.js +25 -7
- package/dataflow/environments/identifier.d.ts +8 -2
- package/dataflow/environments/identifier.js +6 -1
- package/dataflow/environments/query-fn-props.d.ts +6 -0
- package/dataflow/environments/query-fn-props.js +22 -2
- package/dataflow/environments/reference-to-maybe.js +5 -5
- package/dataflow/environments/resolve-by-name.d.ts +3 -0
- package/dataflow/environments/resolve-by-name.js +44 -7
- package/dataflow/environments/resolve-helper.d.ts +6 -0
- package/dataflow/environments/resolve-helper.js +6 -0
- package/dataflow/eval/resolve/alias-tracking.d.ts +5 -0
- package/dataflow/eval/resolve/alias-tracking.js +21 -14
- package/dataflow/eval/resolve/node-value.d.ts +6 -0
- package/dataflow/eval/resolve/node-value.js +15 -9
- package/dataflow/eval/resolve/resolve-argument.js +2 -2
- package/dataflow/eval/resolve/resolve-numbers.js +2 -2
- package/dataflow/eval/resolve/resolve-operators.js +5 -4
- package/dataflow/eval/resolve/resolve-strings.js +3 -3
- package/dataflow/eval/resolve/resolve-working-directory.d.ts +1 -1
- package/dataflow/eval/resolve/resolve-working-directory.js +3 -3
- package/dataflow/eval/resolve/resolve.d.ts +5 -5
- package/dataflow/eval/resolve/resolve.js +10 -11
- package/dataflow/eval/values/general.d.ts +4 -1
- package/dataflow/eval/values/general.js +1 -1
- package/dataflow/extractor.js +2 -1
- package/dataflow/fn/exceptions-of-function.d.ts +3 -1
- package/dataflow/fn/exceptions-of-function.js +87 -39
- package/dataflow/fn/higher-order-function.js +5 -4
- package/dataflow/fn/strict-function.d.ts +40 -0
- package/dataflow/fn/strict-function.js +337 -0
- package/dataflow/graph/call-graph.js +14 -14
- package/dataflow/graph/df-helper.d.ts +24 -1
- package/dataflow/graph/df-helper.js +29 -7
- package/dataflow/graph/diff-dataflow-graph.js +6 -6
- package/dataflow/graph/edge.d.ts +27 -0
- package/dataflow/graph/edge.js +33 -0
- package/dataflow/graph/graph-helper.d.ts +3 -4
- package/dataflow/graph/graph-helper.js +4 -5
- package/dataflow/graph/graph.d.ts +39 -3
- package/dataflow/graph/graph.js +75 -7
- package/dataflow/graph/vertex.d.ts +42 -6
- package/dataflow/graph/vertex.js +42 -6
- package/dataflow/info.d.ts +26 -0
- package/dataflow/info.js +28 -1
- package/dataflow/internal/linker.d.ts +1 -0
- package/dataflow/internal/linker.js +11 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +6 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +6 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +7 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +1 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +19 -18
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +6 -1
- 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.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.js +5 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +1 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +29 -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-source.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +3 -1
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +44 -20
- package/dataflow/internal/process/functions/call/common.d.ts +9 -1
- package/dataflow/internal/process/functions/call/common.js +17 -6
- package/dataflow/internal/process/functions/call/deferred.js +2 -1
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +3 -1
- package/dataflow/internal/process/functions/call/known-call-handling.js +6 -3
- package/dataflow/internal/process/functions/call/named-call-handling.js +44 -12
- package/dataflow/internal/process/functions/call/nse.d.ts +33 -5
- package/dataflow/internal/process/functions/call/nse.js +113 -6
- package/dataflow/internal/process/functions/call/quoted.d.ts +5 -0
- package/dataflow/internal/process/functions/call/quoted.js +21 -9
- package/dataflow/origin/dfg-get-origin.d.ts +1 -0
- package/dataflow/origin/dfg-get-origin.js +9 -6
- package/documentation/data/faq/faqs.js +88 -88
- package/documentation/data/faq/recommended-configs.js +1 -1
- package/documentation/data/faq/wiki-faq-store.js +1 -1
- package/documentation/doc-capabilities.js +1 -1
- package/documentation/doc-readme.js +1 -1
- package/documentation/doc-util/doc-auto-gen.js +6 -2
- package/documentation/doc-util/doc-functions.js +1 -1
- package/documentation/wiki-cfg.js +2 -2
- package/documentation/wiki-core.js +1 -1
- package/documentation/wiki-create-linting-rules.js +45 -45
- package/documentation/wiki-dataflow-graph.js +18 -18
- package/documentation/wiki-linter.js +1 -0
- package/documentation/wiki-linting-and-testing.js +93 -5
- package/documentation/wiki-mk/doc-maker.js +1 -1
- package/documentation/wiki-overview.js +12 -1
- package/documentation/wiki-query.js +53 -0
- package/documentation/wiki-signature-database.js +3 -0
- package/linter/linter-output.js +1 -1
- package/linter/linter-rules.d.ts +24 -0
- package/linter/linter-rules.js +3 -1
- package/linter/rules/file-path-validity.js +1 -1
- package/linter/rules/function-finder-util.js +1 -1
- package/linter/rules/naming-convention.js +1 -1
- package/linter/rules/network-functions.d.ts +1 -1
- package/linter/rules/no-leaked-credentials.js +2 -1
- package/linter/rules/stop-with-call-arg.js +4 -4
- package/linter/rules/unclosed-connection.d.ts +44 -0
- package/linter/rules/unclosed-connection.js +200 -0
- package/linter/rules/undefined-symbol-util.d.ts +1 -1
- package/linter/rules/undefined-symbol-util.js +5 -4
- package/linter/rules/undefined-symbol.js +3 -3
- package/linter/rules/unused-definition.js +2 -1
- package/package.json +38 -51
- package/project/context/flowr-analyzer-environment-context.d.ts +23 -0
- package/project/context/flowr-analyzer-environment-context.js +25 -0
- package/project/dependency-version-space.d.ts +3 -3
- package/project/dependency-version-space.js +3 -4
- package/project/flowr-analyzer.js +1 -1
- package/project/plugins/file-plugins/files/flowr-description-file.d.ts +1 -1
- package/project/plugins/file-plugins/files/flowr-description-file.js +1 -1
- package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +1 -1
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +1 -1
- package/project/plugins/file-plugins/files/flowr-news-file.d.ts +1 -1
- package/project/plugins/file-plugins/files/flowr-news-file.js +1 -1
- package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +1 -1
- package/project/plugins/file-plugins/files/flowr-rda-file.js +4 -4
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +2 -2
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +5 -5
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +36 -7
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +2 -2
- package/project/sigdb/build.js +16 -16
- package/project/sigdb/codec.d.ts +1 -1
- package/project/sigdb/codec.js +13 -13
- package/project/sigdb/decompress.d.ts +1 -1
- package/project/sigdb/decompress.js +33 -33
- package/project/sigdb/index-format.js +2 -2
- package/project/sigdb/manifest.d.ts +3 -1
- package/project/sigdb/manifest.js +68 -27
- package/project/sigdb/memory-source.d.ts +64 -0
- package/project/sigdb/memory-source.js +133 -0
- package/project/sigdb/reader.js +14 -14
- package/project/sigdb/schema.d.ts +2 -2
- package/project/sigdb/schema.js +2 -2
- package/queries/catalog/call-context-query/call-context-query-executor.js +1 -1
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +2 -2
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +2 -2
- package/queries/catalog/dependencies-query/dependencies-query-format.js +1 -1
- package/queries/catalog/dependencies-query/link-devices.js +3 -9
- package/queries/catalog/does-call-query/does-call-query-executor.js +2 -1
- package/queries/catalog/input-sources-query/simple-input-classifier.js +4 -4
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +2 -1
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +1 -0
- package/queries/catalog/inspect-strictness-query/inspect-strictness-query-executor.d.ts +6 -0
- package/queries/catalog/inspect-strictness-query/inspect-strictness-query-executor.js +25 -0
- package/queries/catalog/inspect-strictness-query/inspect-strictness-query-format.d.ts +31 -0
- package/queries/catalog/inspect-strictness-query/inspect-strictness-query-format.js +56 -0
- package/queries/catalog/location-map-query/location-map-query-format.js +1 -1
- package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +2 -2
- package/queries/catalog/signature-query/signature-query-executor.d.ts +2 -0
- package/queries/catalog/signature-query/signature-query-executor.js +3 -2
- package/queries/catalog/slice-query-options.d.ts +1 -1
- package/queries/catalog/slice-query-options.js +1 -1
- package/queries/query-function-filter.d.ts +8 -2
- package/queries/query-function-filter.js +11 -1
- package/queries/query.d.ts +11 -1
- package/queries/query.js +2 -0
- package/r-bridge/lang-4.x/ast/model/model.d.ts +4 -4
- package/r-bridge/lang-4.x/ast/model/model.js +4 -4
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +3 -3
- 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/retriever.d.ts +2 -1
- package/r-bridge/retriever.js +3 -2
- package/r-bridge/roxygen2/documentation-provider.d.ts +1 -0
- package/r-bridge/roxygen2/documentation-provider.js +1 -0
- package/r-bridge/roxygen2/roxygen-parse.d.ts +1 -1
- package/r-bridge/roxygen2/roxygen-parse.js +1 -1
- package/search/flowr-search-filters.d.ts +1 -1
- package/search/flowr-search-filters.js +2 -14
- package/search/search-executor/search-enrichers.js +4 -4
- package/search/search-executor/search-generators.js +1 -1
- package/slicing/criterion/parse.d.ts +2 -2
- package/slicing/criterion/parse.js +5 -5
- package/slicing/static/fingerprint.js +1 -1
- package/slicing/static/slice-call.d.ts +1 -1
- package/slicing/static/slice-call.js +2 -2
- package/slicing/static/static-slicer.js +4 -3
- package/util/assert.js +1 -1
- package/util/log.d.ts +4 -1
- package/util/log.js +15 -2
- package/util/logic.js +2 -2
- package/util/mermaid/cfg.js +1 -1
- package/util/mermaid/dfg.js +6 -6
- package/util/mermaid/mermaid.js +3 -1
- package/util/objects.d.ts +12 -0
- package/util/objects.js +48 -0
- package/util/quads.js +19 -6
- package/util/schema.js +2 -2
- package/util/simple-df/dfg-ascii.js +14 -3
- package/util/text/ansi.d.ts +2 -0
- package/util/text/ansi.js +8 -0
- package/util/text/name-rank.d.ts +29 -0
- package/util/text/name-rank.js +39 -0
- package/util/text/url-encoding.d.ts +15 -0
- package/util/text/url-encoding.js +59 -0
- package/util/version.js +1 -1
- package/cli/export-quads-app.d.ts +0 -7
- package/cli/export-quads-app.js +0 -44
package/dataflow/graph/edge.js
CHANGED
|
@@ -107,6 +107,39 @@ exports.DfEdge = {
|
|
|
107
107
|
doesNotIncludeType({ types }, any) {
|
|
108
108
|
return (any & types) === 0;
|
|
109
109
|
},
|
|
110
|
+
/**
|
|
111
|
+
* Whether the edge carries any type at all.
|
|
112
|
+
* Counterpart of {@link DfEdge#hasNoType}.
|
|
113
|
+
* @example
|
|
114
|
+
*
|
|
115
|
+
* ```ts
|
|
116
|
+
* DfEdge.hasAnyType({ types: EdgeType.Reads }) // true
|
|
117
|
+
* DfEdge.hasAnyType({ types: 0 }) // false
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
hasAnyType({ types }) {
|
|
121
|
+
return types !== 0;
|
|
122
|
+
},
|
|
123
|
+
/**
|
|
124
|
+
* Whether the edge carries no type at all. Such an edge states nothing and has to be removed, not kept.
|
|
125
|
+
* Counterpart of {@link DfEdge#hasAnyType}.
|
|
126
|
+
*/
|
|
127
|
+
hasNoType({ types }) {
|
|
128
|
+
return types === 0;
|
|
129
|
+
},
|
|
130
|
+
/**
|
|
131
|
+
* Check whether the edge carries the given types and nothing else.
|
|
132
|
+
* Strict counterpart of {@link DfEdge#includesType}, which already holds if one of the bits is set.
|
|
133
|
+
* @example
|
|
134
|
+
*
|
|
135
|
+
* ```ts
|
|
136
|
+
* DfEdge.isOnlyType({ types: EdgeType.Reads | EdgeType.Calls }, EdgeType.Reads) // false
|
|
137
|
+
* DfEdge.isOnlyType({ types: EdgeType.Reads | EdgeType.Calls }, EdgeType.Reads | EdgeType.Calls) // true
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
isOnlyType({ types }, only) {
|
|
141
|
+
return types === only;
|
|
142
|
+
},
|
|
110
143
|
};
|
|
111
144
|
const alwaysTraverseEdgeTypes = EdgeType.Reads | EdgeType.DefinedBy | EdgeType.Argument | EdgeType.Calls;
|
|
112
145
|
const definedByOnCallTypes = EdgeType.DefinesOnCall | EdgeType.DefinedByOnCall;
|
|
@@ -9,10 +9,9 @@ import type { AstIdMap } from '../../r-bridge/lang-4.x/ast/model/processing/deco
|
|
|
9
9
|
import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
10
10
|
import { DefaultMap } from '../../util/collections/defaultmap';
|
|
11
11
|
/**
|
|
12
|
-
* The underlying functions which work for any graph* like view
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* - {@link CallGraph}
|
|
12
|
+
* The underlying functions which work for any graph* like view.
|
|
13
|
+
* Use {@link Dataflow} for the dataflow graph and {@link CallGraph} for the call graph, both spread this object in.
|
|
14
|
+
* @useInstead {@link Dataflow}
|
|
16
15
|
*/
|
|
17
16
|
export declare const GraphHelper: {
|
|
18
17
|
readonly name: "GraphHelper";
|
|
@@ -11,10 +11,9 @@ const parse_1 = require("../../slicing/criterion/parse");
|
|
|
11
11
|
const edge_1 = require("./edge");
|
|
12
12
|
const defaultmap_1 = require("../../util/collections/defaultmap");
|
|
13
13
|
/**
|
|
14
|
-
* The underlying functions which work for any graph* like view
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* - {@link CallGraph}
|
|
14
|
+
* The underlying functions which work for any graph* like view.
|
|
15
|
+
* Use {@link Dataflow} for the dataflow graph and {@link CallGraph} for the call graph, both spread this object in.
|
|
16
|
+
* @useInstead {@link Dataflow}
|
|
18
17
|
*/
|
|
19
18
|
exports.GraphHelper = {
|
|
20
19
|
name: 'GraphHelper',
|
|
@@ -115,7 +114,7 @@ exports.GraphHelper = {
|
|
|
115
114
|
return true;
|
|
116
115
|
}
|
|
117
116
|
visited.add(currentId);
|
|
118
|
-
for (const [tar] of graph.outgoingEdges(currentId) ??
|
|
117
|
+
for (const [tar] of graph.outgoingEdges(currentId) ?? graph_1.NoEdges) {
|
|
119
118
|
toVisit.push(tar);
|
|
120
119
|
}
|
|
121
120
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { EdgeType } from './edge';
|
|
2
|
+
import { DfEdge } from './edge';
|
|
2
3
|
import type { DataflowInformation } from '../info';
|
|
3
4
|
import { type DataflowGraphVertexArgument, type DataflowGraphVertexFunctionCall, type DataflowGraphVertexInfo } from './vertex';
|
|
4
5
|
import { EmptyArgument } from '../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
5
|
-
import type { BrandedIdentifier, IdentifierDefinition, IdentifierReference } from '../environments/identifier';
|
|
6
|
+
import type { BrandedIdentifier, Identifier, IdentifierDefinition, IdentifierReference } from '../environments/identifier';
|
|
6
7
|
import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
7
8
|
import { type EnvType, type REnvironmentInformation } from '../environments/environment';
|
|
8
9
|
import type { AstIdMap } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
@@ -141,6 +142,25 @@ export type OutgoingEdges<Edge extends DfEdge = DfEdge> = Map<NodeId, Edge>;
|
|
|
141
142
|
* In other words, it maps the source to the edge information.
|
|
142
143
|
*/
|
|
143
144
|
export type IngoingEdges<Edge extends DfEdge = DfEdge> = Map<NodeId, Edge>;
|
|
145
|
+
/**
|
|
146
|
+
* {@link IngoingEdges} as handed out by {@link DataflowGraph#ingoingEdges|ingoingEdges()}: a vertex without any
|
|
147
|
+
* shares the single {@link NoEdges}, so what a caller gets back is not theirs to write into.
|
|
148
|
+
*/
|
|
149
|
+
export type ReadonlyIngoingEdges<Edge extends DfEdge = DfEdge> = ReadonlyMap<NodeId, Edge>;
|
|
150
|
+
/**
|
|
151
|
+
* The shared answer for a vertex without edges. Use it instead of a fresh `[]` fallback, the lookups sit in
|
|
152
|
+
* traversal loops where a miss is the common case.
|
|
153
|
+
* @example
|
|
154
|
+
* ```ts
|
|
155
|
+
* for(const [target, edge] of graph.outgoingEdges(id) ?? NoEdges) { /* ... *\/ }
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
158
|
+
export declare const NoEdges: ReadonlyMap<NodeId, never>;
|
|
159
|
+
/**
|
|
160
|
+
* Resolves the `pkg::fn` name of the call `id`, without and with the base-R qualification.
|
|
161
|
+
* Passed to {@link DataflowGraph#qualify}, which caches what it returns.
|
|
162
|
+
*/
|
|
163
|
+
export type CallQualifier = (graph: DataflowGraph, id: NodeId, vertex: DataflowGraphVertexInfo | undefined) => readonly [bare: Identifier | undefined, baseR: Identifier | undefined];
|
|
144
164
|
/**
|
|
145
165
|
* The structure of the serialized {@link DataflowGraph}.
|
|
146
166
|
*/
|
|
@@ -209,6 +229,7 @@ export declare class DataflowGraph<Vertex extends DataflowGraphVertexInfo = Data
|
|
|
209
229
|
private edgeInformation;
|
|
210
230
|
private incomingIndex?;
|
|
211
231
|
private readonly types;
|
|
232
|
+
private qualifiedNames?;
|
|
212
233
|
toJSON(): DataflowGraphJson;
|
|
213
234
|
/**
|
|
214
235
|
* Get the {@link DataflowGraphVertexInfo} attached to a node as well as all outgoing edges.
|
|
@@ -235,7 +256,22 @@ export declare class DataflowGraph<Vertex extends DataflowGraphVertexInfo = Data
|
|
|
235
256
|
*/
|
|
236
257
|
getRootVertex(id: NodeId): Vertex | undefined;
|
|
237
258
|
outgoingEdges(id: NodeId): OutgoingEdges | undefined;
|
|
238
|
-
ingoingEdges(id: NodeId):
|
|
259
|
+
ingoingEdges(id: NodeId): ReadonlyIngoingEdges | undefined;
|
|
260
|
+
/**
|
|
261
|
+
* The cached `pkg::fn` name of the call `id`, asking `resolve` only for a call the cache does not know yet.
|
|
262
|
+
* @useInstead {@link Dataflow.qualify} - which passes the resolution
|
|
263
|
+
*/
|
|
264
|
+
qualify(id: NodeId, qualifyBaseR: boolean, resolve: CallQualifier): Identifier | undefined;
|
|
265
|
+
/**
|
|
266
|
+
* The cached `pkg::fn` name of every call, resolving the calls that are still missing.
|
|
267
|
+
* @useInstead {@link Dataflow.qualifyAll} - which passes the resolution
|
|
268
|
+
*/
|
|
269
|
+
qualifyAll(qualifyBaseR: boolean, resolve: CallQualifier): ReadonlyMap<NodeId, Identifier | undefined>;
|
|
270
|
+
private qualifications;
|
|
271
|
+
/** one resolution fills both variants: what costs is resolving the call, not qualifying it */
|
|
272
|
+
private resolveInto;
|
|
273
|
+
/** Drops the cached qualifications, as the graph may no longer imply them */
|
|
274
|
+
private dropQualifications;
|
|
239
275
|
/**
|
|
240
276
|
* Given a node in the normalized AST this either:
|
|
241
277
|
* returns the id if the node directly exists in the DFG
|
package/dataflow/graph/graph.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DataflowGraph = exports.UnknownSideEffect = exports.FunctionArgument = void 0;
|
|
3
|
+
exports.DataflowGraph = exports.UnknownSideEffect = exports.NoEdges = exports.FunctionArgument = void 0;
|
|
4
4
|
const assert_1 = require("../../util/assert");
|
|
5
|
+
const edge_1 = require("./edge");
|
|
5
6
|
const vertex_1 = require("./vertex");
|
|
6
7
|
const arrays_1 = require("../../util/collections/arrays");
|
|
7
8
|
const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
8
9
|
const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
9
10
|
const environment_1 = require("../environments/environment");
|
|
10
11
|
const clone_1 = require("../environments/clone");
|
|
12
|
+
const vertex_2 = require("./vertex");
|
|
11
13
|
/**
|
|
12
14
|
* Helper functions to work with {@link FunctionArgument}s.
|
|
13
15
|
* @see {@link EmptyArgument} - the marker for empty arguments
|
|
@@ -121,6 +123,15 @@ exports.FunctionArgument = {
|
|
|
121
123
|
return exports.FunctionArgument.isNamed(arg) && arg.name === name;
|
|
122
124
|
}
|
|
123
125
|
};
|
|
126
|
+
/**
|
|
127
|
+
* The shared answer for a vertex without edges. Use it instead of a fresh `[]` fallback, the lookups sit in
|
|
128
|
+
* traversal loops where a miss is the common case.
|
|
129
|
+
* @example
|
|
130
|
+
* ```ts
|
|
131
|
+
* for(const [target, edge] of graph.outgoingEdges(id) ?? NoEdges) { /* ... *\/ }
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
exports.NoEdges = new Map();
|
|
124
135
|
/**
|
|
125
136
|
* Helpers for the {@link UnknownSideEffect} union, which is either a plain {@link NodeId} or a
|
|
126
137
|
* `{ id, linkTo }` object. Use these instead of hand-rolling `typeof x === 'object' ? x.id : x`
|
|
@@ -183,6 +194,8 @@ class DataflowGraph {
|
|
|
183
194
|
* edges of many nodes scan the whole graph once per node */
|
|
184
195
|
incomingIndex;
|
|
185
196
|
types = new Map();
|
|
197
|
+
/* the qualified call names, built on demand and dropped on every change, as vertices and edges both decide them */
|
|
198
|
+
qualifiedNames;
|
|
186
199
|
toJSON() {
|
|
187
200
|
return {
|
|
188
201
|
rootVertices: Array.from(this.rootVertices),
|
|
@@ -245,8 +258,56 @@ class DataflowGraph {
|
|
|
245
258
|
}
|
|
246
259
|
this.incomingIndex = index;
|
|
247
260
|
}
|
|
248
|
-
/* the historic contract is an (possibly empty) map for every id, never `undefined
|
|
249
|
-
|
|
261
|
+
/* the historic contract is an (possibly empty) map for every id, never `undefined`; the miss is the common
|
|
262
|
+
* case in traversal loops, so it answers with the shared empty map rather than a fresh one */
|
|
263
|
+
return this.incomingIndex.get(id) ?? exports.NoEdges;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* The cached `pkg::fn` name of the call `id`, asking `resolve` only for a call the cache does not know yet.
|
|
267
|
+
* @useInstead {@link Dataflow.qualify} - which passes the resolution
|
|
268
|
+
*/
|
|
269
|
+
qualify(id, qualifyBaseR, resolve) {
|
|
270
|
+
const cache = this.qualifications();
|
|
271
|
+
const wanted = qualifyBaseR ? cache.baseR : cache.bare;
|
|
272
|
+
const hit = wanted.get(id);
|
|
273
|
+
if (hit !== undefined || wanted.has(id)) {
|
|
274
|
+
return hit;
|
|
275
|
+
}
|
|
276
|
+
this.resolveInto(cache, id, this.vertexInformation.get(id), resolve);
|
|
277
|
+
return wanted.get(id);
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* The cached `pkg::fn` name of every call, resolving the calls that are still missing.
|
|
281
|
+
* @useInstead {@link Dataflow.qualifyAll} - which passes the resolution
|
|
282
|
+
*/
|
|
283
|
+
qualifyAll(qualifyBaseR, resolve) {
|
|
284
|
+
const cache = this.qualifications();
|
|
285
|
+
const wanted = qualifyBaseR ? cache.baseR : cache.bare;
|
|
286
|
+
if (cache.complete) {
|
|
287
|
+
return wanted;
|
|
288
|
+
}
|
|
289
|
+
for (const id of this.types.get(vertex_1.VertexType.FunctionCall) ?? []) {
|
|
290
|
+
if (!wanted.has(id)) {
|
|
291
|
+
this.resolveInto(cache, id, this.vertexInformation.get(id), resolve);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
cache.complete = true;
|
|
295
|
+
return wanted;
|
|
296
|
+
}
|
|
297
|
+
qualifications() {
|
|
298
|
+
return this.qualifiedNames ??= { bare: new Map(), baseR: new Map(), complete: false };
|
|
299
|
+
}
|
|
300
|
+
/** one resolution fills both variants: what costs is resolving the call, not qualifying it */
|
|
301
|
+
resolveInto(cache, id, vertex, resolve) {
|
|
302
|
+
const [bare, baseR] = resolve(this, id, vertex);
|
|
303
|
+
cache.bare.set(id, bare);
|
|
304
|
+
cache.baseR.set(id, baseR);
|
|
305
|
+
}
|
|
306
|
+
/** Drops the cached qualifications, as the graph may no longer imply them */
|
|
307
|
+
dropQualifications() {
|
|
308
|
+
if (this.qualifiedNames !== undefined) {
|
|
309
|
+
this.qualifiedNames = undefined;
|
|
310
|
+
}
|
|
250
311
|
}
|
|
251
312
|
/**
|
|
252
313
|
* Given a node in the normalized AST this either:
|
|
@@ -339,8 +400,9 @@ class DataflowGraph {
|
|
|
339
400
|
if (edge === undefined || targets === undefined) {
|
|
340
401
|
return this;
|
|
341
402
|
}
|
|
403
|
+
this.dropQualifications();
|
|
342
404
|
edge.types &= ~type;
|
|
343
|
-
if (edge
|
|
405
|
+
if (edge_1.DfEdge.hasAnyType(edge)) {
|
|
344
406
|
/* the reverse index holds this very object, so a narrowed type is already visible through it */
|
|
345
407
|
return this;
|
|
346
408
|
}
|
|
@@ -370,6 +432,7 @@ class DataflowGraph {
|
|
|
370
432
|
if (this.vertexInformation.has(vid) && !overwrite) {
|
|
371
433
|
return this;
|
|
372
434
|
}
|
|
435
|
+
this.dropQualifications();
|
|
373
436
|
const vtag = vertex.tag;
|
|
374
437
|
// keep a clone of the original environment, isolating the snapshot from later updates
|
|
375
438
|
vertex.environment = vertex.environment ? (0, clone_1.cloneEnvironmentInformation)(vertex.environment) : (vtag === vertex_1.VertexType.FunctionDefinition || (vtag === vertex_1.VertexType.FunctionCall && !vertex.onlyBuiltin) ? fallbackEnv : undefined);
|
|
@@ -390,6 +453,7 @@ class DataflowGraph {
|
|
|
390
453
|
if (fromId === toId) {
|
|
391
454
|
return this;
|
|
392
455
|
}
|
|
456
|
+
this.dropQualifications();
|
|
393
457
|
const fromEdges = this.edgeInformation.get(fromId);
|
|
394
458
|
const existing = fromEdges?.get(toId);
|
|
395
459
|
if (existing !== undefined) {
|
|
@@ -445,6 +509,7 @@ class DataflowGraph {
|
|
|
445
509
|
return this;
|
|
446
510
|
}
|
|
447
511
|
mergeVertices(otherGraph, mergeRootVertices = true) {
|
|
512
|
+
this.dropQualifications();
|
|
448
513
|
// merge root ids
|
|
449
514
|
if (mergeRootVertices) {
|
|
450
515
|
for (const root of otherGraph.rootVertices) {
|
|
@@ -460,6 +525,7 @@ class DataflowGraph {
|
|
|
460
525
|
}
|
|
461
526
|
}
|
|
462
527
|
mergeEdges(otherGraph) {
|
|
528
|
+
this.dropQualifications();
|
|
463
529
|
this.incomingIndex = undefined;
|
|
464
530
|
for (const [id, edges] of otherGraph.edgeInformation.entries()) {
|
|
465
531
|
let existing = this.edgeInformation.get(id);
|
|
@@ -486,9 +552,10 @@ class DataflowGraph {
|
|
|
486
552
|
* @param sourceIds - The id of the source vertex of the def, if available
|
|
487
553
|
*/
|
|
488
554
|
setDefinitionOfVertex(reference, sourceIds) {
|
|
555
|
+
this.dropQualifications();
|
|
489
556
|
const vertex = this.getVertex(reference.nodeId);
|
|
490
557
|
(0, assert_1.guard)(vertex !== undefined, () => `node must be defined for ${JSON.stringify(reference)} to set reference`);
|
|
491
|
-
if (
|
|
558
|
+
if (vertex_2.FunctionDefinitionVertex.is(vertex) || vertex_2.VariableDefinitionVertex.is(vertex)) {
|
|
492
559
|
vertex.cds = reference.cds;
|
|
493
560
|
}
|
|
494
561
|
else {
|
|
@@ -518,9 +585,10 @@ class DataflowGraph {
|
|
|
518
585
|
* @param info - The information about the new function call node
|
|
519
586
|
*/
|
|
520
587
|
updateToFunctionCall(info) {
|
|
588
|
+
this.dropQualifications();
|
|
521
589
|
const infoId = info.id;
|
|
522
590
|
const vertex = this.getVertex(infoId);
|
|
523
|
-
(0, assert_1.guard)(vertex !== undefined && (
|
|
591
|
+
(0, assert_1.guard)(vertex !== undefined && (vertex_2.UseVertex.is(vertex) || vertex_2.ValueVertex.is(vertex)), () => `node must be a use or value node for ${JSON.stringify(info.id)} to update it to a function call but is ${vertex?.tag}`);
|
|
524
592
|
const previousTag = vertex.tag;
|
|
525
593
|
this.vertexInformation.set(infoId, { ...vertex, ...info, tag: vertex_1.VertexType.FunctionCall });
|
|
526
594
|
const prevIds = this.types.get(previousTag);
|
|
@@ -594,7 +662,7 @@ function mergeNodeInfos(current, next) {
|
|
|
594
662
|
if (current.tag !== next.tag) {
|
|
595
663
|
return current;
|
|
596
664
|
}
|
|
597
|
-
else if (
|
|
665
|
+
else if (vertex_2.FunctionDefinitionVertex.is(current)) {
|
|
598
666
|
const n = next;
|
|
599
667
|
current.exitPoints = (0, arrays_1.uniqueArrayMerge)(current.exitPoints, n.exitPoints);
|
|
600
668
|
if (n.mode && n.mode.length > 0) {
|
|
@@ -176,33 +176,69 @@ export type DataflowGraphVertexInfo = Required<DataflowGraphVertexArgument>;
|
|
|
176
176
|
* A mapping of {@link NodeId}s to {@link DataflowGraphVertexInfo|vertices}.
|
|
177
177
|
*/
|
|
178
178
|
export type DataflowGraphVertices<Vertex extends DataflowGraphVertexInfo = DataflowGraphVertexInfo> = Map<NodeId, Vertex>;
|
|
179
|
-
/**
|
|
179
|
+
/**
|
|
180
|
+
* Helpers for {@link DataflowGraphVertexValue} vertices.
|
|
181
|
+
* @example
|
|
182
|
+
* ```ts
|
|
183
|
+
* ValueVertex.is(graph.getVertex(id)) // true for a constant like `42`
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
180
186
|
export declare const ValueVertex: {
|
|
181
187
|
name: string;
|
|
182
188
|
/** Whether the given vertex is a value vertex. */
|
|
183
189
|
is(this: void, vertex?: DataflowGraphVertexBase): vertex is DataflowGraphVertexValue;
|
|
184
190
|
};
|
|
185
|
-
/**
|
|
191
|
+
/**
|
|
192
|
+
* Helpers for {@link DataflowGraphVertexUse} vertices.
|
|
193
|
+
* @example
|
|
194
|
+
* ```ts
|
|
195
|
+
* UseVertex.is(graph.getVertex(id)) // true for a read of `x`
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
186
198
|
export declare const UseVertex: {
|
|
187
199
|
name: string;
|
|
188
200
|
/** Whether the given vertex is a use vertex. */
|
|
189
201
|
is(this: void, vertex?: DataflowGraphVertexBase): vertex is DataflowGraphVertexUse;
|
|
190
202
|
};
|
|
191
|
-
/**
|
|
203
|
+
/**
|
|
204
|
+
* Helpers for {@link DataflowGraphVertexFunctionCall} vertices.
|
|
205
|
+
* @example
|
|
206
|
+
* ```ts
|
|
207
|
+
* const vertex = graph.getVertex(id);
|
|
208
|
+
* FunctionCallVertex.is(vertex) && vertex.name // the call's effective name
|
|
209
|
+
* FunctionCallVertex.hasOrigin(vertex, 'builtin:eval') // the call is an eval
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
192
212
|
export declare const FunctionCallVertex: {
|
|
193
213
|
name: string;
|
|
194
214
|
/** Whether the given vertex is a function call vertex. */
|
|
195
215
|
is(this: void, vertex?: DataflowGraphVertexBase): vertex is DataflowGraphVertexFunctionCall;
|
|
196
|
-
/**
|
|
216
|
+
/**
|
|
217
|
+
* Whether the given vertex is a function call carrying the given origin.
|
|
218
|
+
* Deliberately not a type predicate: a `false` says nothing about the tag, the call may simply carry another origin.
|
|
219
|
+
*/
|
|
197
220
|
hasOrigin(this: void, vertex: DataflowGraphVertexBase | undefined, origin: BuiltInProcName): boolean;
|
|
198
221
|
};
|
|
199
|
-
/**
|
|
222
|
+
/**
|
|
223
|
+
* Helpers for {@link DataflowGraphVertexVariableDefinition} vertices.
|
|
224
|
+
* @example
|
|
225
|
+
* ```ts
|
|
226
|
+
* VariableDefinitionVertex.is(graph.getVertex(id)) // true for the `x` of `x <- 1`
|
|
227
|
+
* ```
|
|
228
|
+
*/
|
|
200
229
|
export declare const VariableDefinitionVertex: {
|
|
201
230
|
name: string;
|
|
202
231
|
/** Whether the given vertex is a variable definition vertex. */
|
|
203
232
|
is(this: void, vertex?: DataflowGraphVertexBase): vertex is DataflowGraphVertexVariableDefinition;
|
|
204
233
|
};
|
|
205
|
-
/**
|
|
234
|
+
/**
|
|
235
|
+
* Helpers for {@link DataflowGraphVertexFunctionDefinition} vertices.
|
|
236
|
+
* @example
|
|
237
|
+
* ```ts
|
|
238
|
+
* const vertex = graph.getVertex(id);
|
|
239
|
+
* FunctionDefinitionVertex.is(vertex) && vertex.exitPoints // where the body returns
|
|
240
|
+
* ```
|
|
241
|
+
*/
|
|
206
242
|
export declare const FunctionDefinitionVertex: {
|
|
207
243
|
name: string;
|
|
208
244
|
/** Whether the given vertex is a function definition vertex. */
|
package/dataflow/graph/vertex.js
CHANGED
|
@@ -11,7 +11,13 @@ var VertexType;
|
|
|
11
11
|
})(VertexType || (exports.VertexType = VertexType = {}));
|
|
12
12
|
exports.ValidVertexTypes = new Set(Object.values(VertexType));
|
|
13
13
|
exports.ValidVertexTypeReverse = Object.fromEntries(Object.entries(VertexType).map(([k, v]) => [v, k]));
|
|
14
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Helpers for {@link DataflowGraphVertexValue} vertices.
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* ValueVertex.is(graph.getVertex(id)) // true for a constant like `42`
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
15
21
|
exports.ValueVertex = {
|
|
16
22
|
name: 'ValueVertex',
|
|
17
23
|
/** Whether the given vertex is a value vertex. */
|
|
@@ -19,7 +25,13 @@ exports.ValueVertex = {
|
|
|
19
25
|
return vertex?.tag === VertexType.Value;
|
|
20
26
|
}
|
|
21
27
|
};
|
|
22
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* Helpers for {@link DataflowGraphVertexUse} vertices.
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* UseVertex.is(graph.getVertex(id)) // true for a read of `x`
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
23
35
|
exports.UseVertex = {
|
|
24
36
|
name: 'UseVertex',
|
|
25
37
|
/** Whether the given vertex is a use vertex. */
|
|
@@ -27,19 +39,36 @@ exports.UseVertex = {
|
|
|
27
39
|
return vertex?.tag === VertexType.Use;
|
|
28
40
|
}
|
|
29
41
|
};
|
|
30
|
-
/**
|
|
42
|
+
/**
|
|
43
|
+
* Helpers for {@link DataflowGraphVertexFunctionCall} vertices.
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* const vertex = graph.getVertex(id);
|
|
47
|
+
* FunctionCallVertex.is(vertex) && vertex.name // the call's effective name
|
|
48
|
+
* FunctionCallVertex.hasOrigin(vertex, 'builtin:eval') // the call is an eval
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
31
51
|
exports.FunctionCallVertex = {
|
|
32
52
|
name: 'FunctionCallVertex',
|
|
33
53
|
/** Whether the given vertex is a function call vertex. */
|
|
34
54
|
is(vertex) {
|
|
35
55
|
return vertex?.tag === VertexType.FunctionCall;
|
|
36
56
|
},
|
|
37
|
-
/**
|
|
57
|
+
/**
|
|
58
|
+
* Whether the given vertex is a function call carrying the given origin.
|
|
59
|
+
* Deliberately not a type predicate: a `false` says nothing about the tag, the call may simply carry another origin.
|
|
60
|
+
*/
|
|
38
61
|
hasOrigin(vertex, origin) {
|
|
39
62
|
return exports.FunctionCallVertex.is(vertex) && vertex.origin.includes(origin);
|
|
40
63
|
}
|
|
41
64
|
};
|
|
42
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* Helpers for {@link DataflowGraphVertexVariableDefinition} vertices.
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* VariableDefinitionVertex.is(graph.getVertex(id)) // true for the `x` of `x <- 1`
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
43
72
|
exports.VariableDefinitionVertex = {
|
|
44
73
|
name: 'VariableDefinitionVertex',
|
|
45
74
|
/** Whether the given vertex is a variable definition vertex. */
|
|
@@ -47,7 +76,14 @@ exports.VariableDefinitionVertex = {
|
|
|
47
76
|
return vertex?.tag === VertexType.VariableDefinition;
|
|
48
77
|
}
|
|
49
78
|
};
|
|
50
|
-
/**
|
|
79
|
+
/**
|
|
80
|
+
* Helpers for {@link DataflowGraphVertexFunctionDefinition} vertices.
|
|
81
|
+
* @example
|
|
82
|
+
* ```ts
|
|
83
|
+
* const vertex = graph.getVertex(id);
|
|
84
|
+
* FunctionDefinitionVertex.is(vertex) && vertex.exitPoints // where the body returns
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
51
87
|
exports.FunctionDefinitionVertex = {
|
|
52
88
|
name: 'FunctionDefinitionVertex',
|
|
53
89
|
/** Whether the given vertex is a function definition vertex. */
|
package/dataflow/info.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type { REnvironmentInformation } from './environments/environment';
|
|
|
5
5
|
import { DataflowGraph } from './graph/graph';
|
|
6
6
|
import type { GenericDifferenceInformation, WriteableDifferenceReport } from '../util/diff';
|
|
7
7
|
import type { HookInformation } from './hooks';
|
|
8
|
+
import type { AstIdMap } from '../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
8
9
|
/**
|
|
9
10
|
* A control dependency links a vertex to the control flow element which
|
|
10
11
|
* may have an influence on its execution.
|
|
@@ -24,6 +25,30 @@ export interface ControlDependency {
|
|
|
24
25
|
*/
|
|
25
26
|
readonly file?: string;
|
|
26
27
|
}
|
|
28
|
+
/** Whether the two control dependencies trigger on the same condition and branch. */
|
|
29
|
+
declare function sameControlDependency(a: ControlDependency, b: ControlDependency): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Utility functions to work with {@link ControlDependency|control dependencies}.
|
|
32
|
+
*/
|
|
33
|
+
export declare const ControlDependency: {
|
|
34
|
+
readonly name: "ControlDependency";
|
|
35
|
+
/** Whether the two trigger on the same condition and branch. */
|
|
36
|
+
readonly same: typeof sameControlDependency;
|
|
37
|
+
/** @see {@link appendCds} */
|
|
38
|
+
readonly append: typeof appendCds;
|
|
39
|
+
/** @see {@link withCds} */
|
|
40
|
+
readonly with: typeof withCds;
|
|
41
|
+
/** @see {@link negateControlDependency} */
|
|
42
|
+
readonly negate: typeof negateControlDependency;
|
|
43
|
+
/** @see {@link happensInEveryBranch} */
|
|
44
|
+
readonly happensInEveryBranch: typeof happensInEveryBranch;
|
|
45
|
+
/** @see {@link happensInEveryBranchSet} */
|
|
46
|
+
readonly happensInEveryBranchSet: typeof happensInEveryBranchSet;
|
|
47
|
+
/** Whether the dependency stems from a loop, so what it guards may happen more than once. */
|
|
48
|
+
readonly isIterated: (this: void, cd: ControlDependency, idMap: AstIdMap | undefined) => boolean;
|
|
49
|
+
/** The dependencies of `a` that `b` is not subject to as well. */
|
|
50
|
+
readonly minus: (this: void, a: readonly ControlDependency[], b: readonly ControlDependency[]) => ControlDependency[];
|
|
51
|
+
};
|
|
27
52
|
/** Appends the given control dependencies to `target`, skipping the ones that are already in there. */
|
|
28
53
|
export declare function appendCds(target: ControlDependency[], toAdd: readonly ControlDependency[] | undefined): void;
|
|
29
54
|
/** A copy of `base` with `toAdd` appended, skipping the control dependencies that are already in there. */
|
|
@@ -201,3 +226,4 @@ export declare function diffControlDependency<Report extends WriteableDifference
|
|
|
201
226
|
* Calculates the difference between two lists of control dependencies.
|
|
202
227
|
*/
|
|
203
228
|
export declare function diffControlDependencies<Report extends WriteableDifferenceReport>(a: ControlDependency[] | undefined, b: ControlDependency[] | undefined, info: GenericDifferenceInformation<Report>): void;
|
|
229
|
+
export {};
|
package/dataflow/info.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DataflowInformation = void 0;
|
|
3
|
+
exports.DataflowInformation = exports.ControlDependency = void 0;
|
|
4
4
|
exports.appendCds = appendCds;
|
|
5
5
|
exports.withCds = withCds;
|
|
6
6
|
exports.negateControlDependency = negateControlDependency;
|
|
@@ -15,10 +15,37 @@ exports.diffControlDependency = diffControlDependency;
|
|
|
15
15
|
exports.diffControlDependencies = diffControlDependencies;
|
|
16
16
|
const graph_1 = require("./graph/graph");
|
|
17
17
|
const assert_1 = require("../util/assert");
|
|
18
|
+
const model_1 = require("../r-bridge/lang-4.x/ast/model/model");
|
|
18
19
|
/** Whether the two control dependencies trigger on the same condition and branch. */
|
|
19
20
|
function sameControlDependency(a, b) {
|
|
20
21
|
return a.id === b.id && a.when === b.when;
|
|
21
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Utility functions to work with {@link ControlDependency|control dependencies}.
|
|
25
|
+
*/
|
|
26
|
+
exports.ControlDependency = {
|
|
27
|
+
name: 'ControlDependency',
|
|
28
|
+
/** Whether the two trigger on the same condition and branch. */
|
|
29
|
+
same: sameControlDependency,
|
|
30
|
+
/** @see {@link appendCds} */
|
|
31
|
+
append: appendCds,
|
|
32
|
+
/** @see {@link withCds} */
|
|
33
|
+
with: withCds,
|
|
34
|
+
/** @see {@link negateControlDependency} */
|
|
35
|
+
negate: negateControlDependency,
|
|
36
|
+
/** @see {@link happensInEveryBranch} */
|
|
37
|
+
happensInEveryBranch,
|
|
38
|
+
/** @see {@link happensInEveryBranchSet} */
|
|
39
|
+
happensInEveryBranchSet,
|
|
40
|
+
/** Whether the dependency stems from a loop, so what it guards may happen more than once. */
|
|
41
|
+
isIterated(cd, idMap) {
|
|
42
|
+
return cd.byIteration === true || model_1.RLoopConstructs.loopConstructTypes.has(idMap?.get(cd.id)?.type);
|
|
43
|
+
},
|
|
44
|
+
/** The dependencies of `a` that `b` is not subject to as well. */
|
|
45
|
+
minus(a, b) {
|
|
46
|
+
return a.filter(cd => !b.some(other => sameControlDependency(other, cd)));
|
|
47
|
+
}
|
|
48
|
+
};
|
|
22
49
|
/** Appends the given control dependencies to `target`, skipping the ones that are already in there. */
|
|
23
50
|
function appendCds(target, toAdd) {
|
|
24
51
|
if (!toAdd) {
|
|
@@ -93,6 +93,7 @@ export declare function getAllLinkedFunctionDefinitions(functionDefinitionReadId
|
|
|
93
93
|
/**
|
|
94
94
|
* Links every name in the expression rooted at `expr` against `environment`, as if it were written there, and
|
|
95
95
|
* hands back what stays unresolved. This is how an expression that was captured elsewhere is read here.
|
|
96
|
+
* @useInstead {@link Quoted.evaluateIn}
|
|
96
97
|
*/
|
|
97
98
|
export declare function linkExpressionIn<Info>(this: void, graph: DataflowGraph, expr: NodeId, environment: REnvironmentInformation, idMap: AstIdMap<Info & ParentInformation>): readonly IdentifierReference[];
|
|
98
99
|
/**
|