@eagleoutice/flowr 2.13.15 → 2.14.0
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 +31 -37
- 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/abstract-interpretation/unsupported-functions.d.ts +1 -0
- package/abstract-interpretation/unsupported-functions.js +1 -0
- package/benchmark/calibration.d.ts +12 -5
- package/benchmark/calibration.js +42 -14
- package/benchmark/slicer.d.ts +1 -1
- package/benchmark/slicer.js +5 -4
- 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/common/options.d.ts +0 -31
- package/cli/common/options.js +1 -8
- package/cli/common/scripts-info.d.ts +0 -38
- package/cli/common/scripts-info.js +0 -8
- package/cli/repl/commands/repl-query.js +37 -2
- package/cli/repl/core.js +6 -3
- 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 +79 -0
- package/control-flow/control-flow-graph.d.ts +2 -0
- package/control-flow/control-flow-graph.js +2 -0
- 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/built-in-props.d.ts +8 -1
- package/dataflow/environments/built-in-props.js +18 -0
- 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 +442 -10
- package/dataflow/environments/default-builtin-config.js +188 -18
- package/dataflow/environments/environment.d.ts +1 -1
- package/dataflow/environments/identifier.d.ts +7 -2
- package/dataflow/environments/identifier.js +6 -1
- package/dataflow/environments/query-fn-props.js +2 -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 +30 -5
- 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 +4 -3
- package/dataflow/eval/resolve/resolve-strings.js +3 -3
- package/dataflow/eval/resolve/resolve-working-directory.js +2 -1
- 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 +4 -1
- package/dataflow/extractor.js +2 -1
- package/dataflow/fn/exceptions-of-function.js +5 -4
- package/dataflow/fn/higher-order-function.d.ts +1 -1
- package/dataflow/fn/higher-order-function.js +22 -2
- package/dataflow/graph/call-graph.d.ts +1 -1
- package/dataflow/graph/call-graph.js +15 -15
- package/dataflow/graph/df-helper.d.ts +17 -2
- package/dataflow/graph/df-helper.js +11 -5
- 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 +4 -4
- package/dataflow/graph/graph-helper.js +5 -5
- package/dataflow/graph/graph.d.ts +11 -1
- package/dataflow/graph/graph.js +16 -5
- package/dataflow/graph/vertex.d.ts +47 -6
- package/dataflow/graph/vertex.js +47 -6
- 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.js +2 -2
- 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.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +8 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-string-template.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 +15 -12
- 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.d.ts +7 -0
- package/dataflow/internal/process/functions/call/deferred.js +24 -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 +34 -5
- package/dataflow/internal/process/functions/call/nse.js +114 -6
- package/dataflow/internal/process/functions/call/quoted.d.ts +6 -0
- package/dataflow/internal/process/functions/call/quoted.js +26 -11
- 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-create-linting-rules.js +45 -45
- package/documentation/wiki-dataflow-graph.js +25 -18
- 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-signature-database.js +3 -0
- package/linter/linter-format.d.ts +1 -0
- package/linter/linter-format.js +1 -0
- 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/no-leaked-credentials.js +2 -1
- package/linter/rules/stop-with-call-arg.js +4 -4
- 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 +35 -45
- 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.js +1 -2
- package/project/flowr-analyzer.js +1 -1
- package/project/plugins/file-plugins/files/flowr-rda-file.js +3 -3
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +2 -2
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +3 -1
- 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.js +21 -21
- package/project/sigdb/memory-source.d.ts +64 -0
- package/project/sigdb/memory-source.js +133 -0
- package/project/sigdb/reader.js +13 -13
- package/queries/catalog/absint-query/absint-query-format.js +1 -1
- 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 +2 -2
- package/queries/catalog/does-call-query/does-call-query-executor.js +2 -1
- package/queries/catalog/does-call-query/does-call-query-format.js +2 -1
- package/queries/catalog/input-sources-query/input-sources-query-format.js +1 -1
- package/queries/catalog/input-sources-query/simple-input-classifier.js +4 -4
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +1 -1
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +1 -1
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +1 -1
- package/queries/catalog/location-map-query/location-map-query-format.js +2 -2
- package/queries/catalog/origin-query/origin-query-format.js +1 -1
- package/queries/catalog/provenance-query/provenance-query-format.js +1 -1
- package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +2 -2
- package/queries/catalog/resolve-value-query/resolve-value-query-format.js +1 -1
- package/queries/catalog/signature-query/signature-query-executor.d.ts +2 -0
- package/queries/catalog/signature-query/signature-query-executor.js +3 -2
- package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.js +1 -0
- 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 -2
- package/search/search-executor/search-enrichers.js +4 -4
- package/search/search-executor/search-generators.js +1 -1
- package/slicing/criterion/parse.d.ts +1 -0
- package/slicing/criterion/parse.js +4 -3
- 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/quads.js +19 -6
- package/util/r-version.d.ts +2 -0
- package/util/r-version.js +2 -0
- package/util/record.d.ts +1 -0
- package/util/record.js +1 -0
- package/util/schema.js +2 -2
- 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
|
@@ -43,7 +43,7 @@ function fallbackUntargetedCall(vtx, graph) {
|
|
|
43
43
|
continue;
|
|
44
44
|
}
|
|
45
45
|
let addedNew = false;
|
|
46
|
-
for (const [tar, e] of graph.outgoingEdges(currentId) ??
|
|
46
|
+
for (const [tar, e] of graph.outgoingEdges(currentId) ?? graph_1.NoEdges) {
|
|
47
47
|
if (edge_1.DfEdge.includesType(e, UntargetedCallFollow) && edge_1.DfEdge.doesNotIncludeType(e, UntargetedCallAvoid)) {
|
|
48
48
|
addedNew = true;
|
|
49
49
|
toVisit.push(tar);
|
|
@@ -79,7 +79,7 @@ function processCall(vtx, from, graph, result, state) {
|
|
|
79
79
|
continue;
|
|
80
80
|
}
|
|
81
81
|
const targetVtx = graph.getVertex(tar);
|
|
82
|
-
if (
|
|
82
|
+
if (!vertex_1.FunctionDefinitionVertex.is(targetVtx)) {
|
|
83
83
|
continue;
|
|
84
84
|
}
|
|
85
85
|
addedTarget = true;
|
|
@@ -89,7 +89,7 @@ function processCall(vtx, from, graph, result, state) {
|
|
|
89
89
|
for (const origs of vtx.origin) {
|
|
90
90
|
if (origs.startsWith('builtin:')) {
|
|
91
91
|
addedTarget = true;
|
|
92
|
-
result.addEdge(vid, node_id_1.NodeId.toBuiltIn(origs.
|
|
92
|
+
result.addEdge(vid, node_id_1.NodeId.toBuiltIn(origs.slice('builtin:'.length)), edge_1.EdgeType.Calls);
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
}
|
|
@@ -102,7 +102,7 @@ function processCall(vtx, from, graph, result, state) {
|
|
|
102
102
|
}
|
|
103
103
|
result.addEdge(vid, ori, edge_1.EdgeType.Calls);
|
|
104
104
|
const name = graph.idMap?.get(ori);
|
|
105
|
-
if (name?.lexeme &&
|
|
105
|
+
if (name?.lexeme && vertex_1.UseVertex.is(oriVtx)) {
|
|
106
106
|
result.addVertex({
|
|
107
107
|
...oriVtx,
|
|
108
108
|
tag: vertex_1.VertexType.FunctionCall,
|
|
@@ -115,7 +115,7 @@ function processCall(vtx, from, graph, result, state) {
|
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
// handle arguments, traversing the 'reads' and the 'returns' edges
|
|
118
|
-
for (const [tar, e] of graph.outgoingEdges(vtx.id) ??
|
|
118
|
+
for (const [tar, e] of graph.outgoingEdges(vtx.id) ?? graph_1.NoEdges) {
|
|
119
119
|
if (edge_1.DfEdge.doesNotIncludeType(e, edge_1.EdgeType.Reads | edge_1.EdgeType.Returns | edge_1.EdgeType.Argument)) {
|
|
120
120
|
continue;
|
|
121
121
|
}
|
|
@@ -168,7 +168,7 @@ function followCalls(graph, seeds, reached) {
|
|
|
168
168
|
continue;
|
|
169
169
|
}
|
|
170
170
|
reached.add(current);
|
|
171
|
-
for (const [target, edge] of graph.outgoingEdges(current) ??
|
|
171
|
+
for (const [target, edge] of graph.outgoingEdges(current) ?? graph_1.NoEdges) {
|
|
172
172
|
if (edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Calls)) {
|
|
173
173
|
toVisit.push(target);
|
|
174
174
|
}
|
|
@@ -180,7 +180,7 @@ function reachedCallNames(graph, reached) {
|
|
|
180
180
|
const names = new Set();
|
|
181
181
|
for (const id of reached) {
|
|
182
182
|
const vertex = graph.getVertex(id);
|
|
183
|
-
if (
|
|
183
|
+
if (vertex_1.FunctionCallVertex.is(vertex)) {
|
|
184
184
|
names.add(identifier_1.Identifier.getName(vertex.name));
|
|
185
185
|
}
|
|
186
186
|
}
|
|
@@ -207,7 +207,7 @@ function mayRunAnyway(graph, reached) {
|
|
|
207
207
|
const seeds = [];
|
|
208
208
|
let generics;
|
|
209
209
|
for (const [id, vertex] of graph.vertices(true)) {
|
|
210
|
-
if (
|
|
210
|
+
if (!vertex_1.FunctionDefinitionVertex.is(vertex) || reached.has(id)) {
|
|
211
211
|
continue;
|
|
212
212
|
}
|
|
213
213
|
const node = idMap.get(id);
|
|
@@ -233,8 +233,8 @@ function mayRunAnyway(graph, reached) {
|
|
|
233
233
|
* @see {@link CallGraph}
|
|
234
234
|
*/
|
|
235
235
|
exports.CallGraph = {
|
|
236
|
-
name: 'CallGraph',
|
|
237
236
|
...graph_helper_1.GraphHelper,
|
|
237
|
+
name: 'CallGraph',
|
|
238
238
|
/**
|
|
239
239
|
* Extracts the sub call graph from the given call graph, starting from the given entry points.
|
|
240
240
|
*/
|
|
@@ -253,7 +253,7 @@ exports.CallGraph = {
|
|
|
253
253
|
continue;
|
|
254
254
|
}
|
|
255
255
|
result.addVertex(currentVtx, undefined, true);
|
|
256
|
-
for (const [tar, e] of graph.outgoingEdges(currentId) ??
|
|
256
|
+
for (const [tar, e] of graph.outgoingEdges(currentId) ?? graph_1.NoEdges) {
|
|
257
257
|
if (edge_1.DfEdge.includesType(e, edge_1.EdgeType.Calls)) {
|
|
258
258
|
result.addEdge(currentId, tar, edge_1.EdgeType.Calls);
|
|
259
259
|
toVisit.push(tar);
|
|
@@ -270,7 +270,7 @@ exports.CallGraph = {
|
|
|
270
270
|
return entries;
|
|
271
271
|
}
|
|
272
272
|
for (const [id, vertex] of graph.vertices(true)) {
|
|
273
|
-
const node =
|
|
273
|
+
const node = vertex_1.FunctionCallVertex.is(vertex) ? idMap.get(id) : undefined;
|
|
274
274
|
if (node !== undefined && r_function_definition_1.RFunctionDefinition.wrappingFunctionDefinition(node, idMap) === undefined) {
|
|
275
275
|
entries.add(id);
|
|
276
276
|
}
|
|
@@ -288,7 +288,7 @@ exports.CallGraph = {
|
|
|
288
288
|
followCalls(graph, seeds, reached);
|
|
289
289
|
}
|
|
290
290
|
return graph.vertices(true)
|
|
291
|
-
.filter(([id, vertex]) =>
|
|
291
|
+
.filter(([id, vertex]) => vertex_1.FunctionCallVertex.is(vertex) && !reached.has(id))
|
|
292
292
|
.map(([id]) => id)
|
|
293
293
|
.toArray();
|
|
294
294
|
},
|
|
@@ -322,10 +322,10 @@ exports.CallGraph = {
|
|
|
322
322
|
potentials: []
|
|
323
323
|
};
|
|
324
324
|
for (const [, vert] of graph.vertices(false)) {
|
|
325
|
-
if (
|
|
325
|
+
if (vertex_1.FunctionCallVertex.is(vert)) {
|
|
326
326
|
processCall(vert, undefined, graph, result, state);
|
|
327
327
|
}
|
|
328
|
-
else if (
|
|
328
|
+
else if (vertex_1.FunctionDefinitionVertex.is(vert)) {
|
|
329
329
|
processFunctionDefinition(vert, undefined, graph, result, state);
|
|
330
330
|
}
|
|
331
331
|
}
|
|
@@ -335,7 +335,7 @@ exports.CallGraph = {
|
|
|
335
335
|
const v = graph.getVertex(to);
|
|
336
336
|
if (v) {
|
|
337
337
|
processUnknown(v, from, graph, result, state);
|
|
338
|
-
if (
|
|
338
|
+
if (vertex_1.FunctionDefinitionVertex.is(v)) {
|
|
339
339
|
processFunctionDefinition(v, from, graph, result, state);
|
|
340
340
|
}
|
|
341
341
|
}
|
|
@@ -18,8 +18,15 @@ import { Identifier } from '../environments/identifier';
|
|
|
18
18
|
* - {@link Dataflow.resolve} - for resolving a name against an environment,
|
|
19
19
|
* - {@link Dataflow.packagesOf} - for the packages a set of nodes (e.g. a slice) calls into,
|
|
20
20
|
* - {@link Dataflow.valueIsUsed}/{@link Dataflow.hasComputedArguments} - for what a call does with, and gets as, values,
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* Dataflow.origin(graph, id); // where the use at `id` comes from
|
|
24
|
+
* Dataflow.edge.includesType(edge, EdgeType.Reads); // the edge helpers
|
|
25
|
+
* Dataflow.visualize.mermaid.url(graph); // a link to the rendered graph
|
|
26
|
+
* ```
|
|
21
27
|
*/
|
|
22
28
|
export declare const Dataflow: {
|
|
29
|
+
readonly name: "Dataflow";
|
|
23
30
|
/**
|
|
24
31
|
* Maps to flowR's dataflow edge helper to work with the edges in the dataflow graph
|
|
25
32
|
*/
|
|
@@ -38,6 +45,15 @@ export declare const Dataflow: {
|
|
|
38
45
|
readonly doesNotIncludeType: (this: void, { types }: {
|
|
39
46
|
types: number;
|
|
40
47
|
}, any: EdgeType) => boolean;
|
|
48
|
+
readonly hasAnyType: (this: void, { types }: {
|
|
49
|
+
types: number;
|
|
50
|
+
}) => boolean;
|
|
51
|
+
readonly hasNoType: (this: void, { types }: {
|
|
52
|
+
types: number;
|
|
53
|
+
}) => boolean;
|
|
54
|
+
readonly isOnlyType: (this: void, { types }: {
|
|
55
|
+
types: number;
|
|
56
|
+
}, only: EdgeType) => boolean;
|
|
41
57
|
};
|
|
42
58
|
/**
|
|
43
59
|
* Dispatches to helper objects that relate to (sub-) views of the dataflow graph, e.g. the call graph.
|
|
@@ -47,6 +63,7 @@ export declare const Dataflow: {
|
|
|
47
63
|
* Maps to flowR's helper object for the call-graph
|
|
48
64
|
*/
|
|
49
65
|
readonly callGraph: {
|
|
66
|
+
readonly name: "CallGraph";
|
|
50
67
|
readonly computeSubCallGraph: (this: void, graph: CallGraph, entryPoints: Set<NodeId>) => CallGraph;
|
|
51
68
|
readonly entryPoints: (this: void, graph: CallGraph) => Set<NodeId>;
|
|
52
69
|
readonly unreachableCalls: (this: void, graph: CallGraph) => NodeId[];
|
|
@@ -70,7 +87,6 @@ export declare const Dataflow: {
|
|
|
70
87
|
readonly invertGraph: <G extends DataflowGraph>(this: void, graph: G, cleanEnv: REnvironmentInformation) => G;
|
|
71
88
|
readonly resolveGraphCriteria: <G extends DataflowGraph>(graph: G, ctx: import("../../project/context/flowr-analyzer-context").ReadOnlyFlowrAnalyzerContext, idMap?: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").AstIdMap) => G;
|
|
72
89
|
readonly reaches: <G extends DataflowGraph>(this: void, from: NodeId, to: NodeId, graph: G, knownReachability?: import("../../util/collections/defaultmap").DefaultMap<NodeId, Set<NodeId>>) => boolean;
|
|
73
|
-
readonly name: "CallGraph";
|
|
74
90
|
};
|
|
75
91
|
};
|
|
76
92
|
/**
|
|
@@ -227,7 +243,6 @@ export declare const Dataflow: {
|
|
|
227
243
|
readonly invertGraph: <G extends DataflowGraph>(this: void, graph: G, cleanEnv: REnvironmentInformation) => G;
|
|
228
244
|
readonly resolveGraphCriteria: <G extends DataflowGraph>(graph: G, ctx: import("../../project/context/flowr-analyzer-context").ReadOnlyFlowrAnalyzerContext, idMap?: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").AstIdMap) => G;
|
|
229
245
|
readonly reaches: <G extends DataflowGraph>(this: void, from: NodeId, to: NodeId, graph: G, knownReachability?: import("../../util/collections/defaultmap").DefaultMap<NodeId, Set<NodeId>>) => boolean;
|
|
230
|
-
readonly name: "Dataflow";
|
|
231
246
|
/**
|
|
232
247
|
* Maps to flowR's main graph object to store and manipulate the dataflow graph
|
|
233
248
|
* @see {@link DataflowGraph}
|
|
@@ -24,15 +24,21 @@ const r_base_packages_1 = require("../../util/r-base-packages");
|
|
|
24
24
|
* - {@link Dataflow.resolve} - for resolving a name against an environment,
|
|
25
25
|
* - {@link Dataflow.packagesOf} - for the packages a set of nodes (e.g. a slice) calls into,
|
|
26
26
|
* - {@link Dataflow.valueIsUsed}/{@link Dataflow.hasComputedArguments} - for what a call does with, and gets as, values,
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* Dataflow.origin(graph, id); // where the use at `id` comes from
|
|
30
|
+
* Dataflow.edge.includesType(edge, EdgeType.Reads); // the edge helpers
|
|
31
|
+
* Dataflow.visualize.mermaid.url(graph); // a link to the rendered graph
|
|
32
|
+
* ```
|
|
27
33
|
*/
|
|
28
34
|
exports.Dataflow = {
|
|
29
|
-
name: 'Dataflow',
|
|
30
35
|
/**
|
|
31
36
|
* Maps to flowR's main graph object to store and manipulate the dataflow graph
|
|
32
37
|
* @see {@link DataflowGraph}
|
|
33
38
|
*/
|
|
34
39
|
graph: graph_1.DataflowGraph,
|
|
35
40
|
...graph_helper_1.GraphHelper,
|
|
41
|
+
name: 'Dataflow',
|
|
36
42
|
/**
|
|
37
43
|
* Maps to flowR's dataflow edge helper to work with the edges in the dataflow graph
|
|
38
44
|
*/
|
|
@@ -115,8 +121,8 @@ exports.Dataflow = {
|
|
|
115
121
|
*/
|
|
116
122
|
valueIsUsed(id, graph) {
|
|
117
123
|
const consuming = edge_1.EdgeType.Argument | edge_1.EdgeType.Returns | edge_1.EdgeType.DefinedBy;
|
|
118
|
-
for (const [, edge] of graph.ingoingEdges(id) ??
|
|
119
|
-
if ((edge
|
|
124
|
+
for (const [, edge] of graph.ingoingEdges(id) ?? graph_1.NoEdges) {
|
|
125
|
+
if (edge_1.DfEdge.includesType(edge, consuming)) {
|
|
120
126
|
return true;
|
|
121
127
|
}
|
|
122
128
|
}
|
|
@@ -128,8 +134,8 @@ exports.Dataflow = {
|
|
|
128
134
|
* A call among the arguments counts as computed, even one over literals such as `paste("a", "b")`.
|
|
129
135
|
*/
|
|
130
136
|
hasComputedArguments(id, graph) {
|
|
131
|
-
for (const [target] of graph.outgoingEdges(id) ??
|
|
132
|
-
if (!node_id_1.NodeId.isBuiltIn(target) && graph.getVertex(target)
|
|
137
|
+
for (const [target] of graph.outgoingEdges(id) ?? graph_1.NoEdges) {
|
|
138
|
+
if (!node_id_1.NodeId.isBuiltIn(target) && !vertex_1.ValueVertex.is(graph.getVertex(target))) {
|
|
133
139
|
return true;
|
|
134
140
|
}
|
|
135
141
|
}
|
|
@@ -8,7 +8,6 @@ const graph_1 = require("./graph");
|
|
|
8
8
|
const diff_1 = require("../../util/diff");
|
|
9
9
|
const json_1 = require("../../util/json");
|
|
10
10
|
const arrays_1 = require("../../util/collections/arrays");
|
|
11
|
-
const vertex_1 = require("./vertex");
|
|
12
11
|
const edge_1 = require("./edge");
|
|
13
12
|
const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
14
13
|
const identifier_1 = require("../environments/identifier");
|
|
@@ -16,6 +15,7 @@ const diff_2 = require("../environments/diff");
|
|
|
16
15
|
const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
17
16
|
const info_1 = require("../info");
|
|
18
17
|
const diff_graph_1 = require("../../util/diff-graph");
|
|
18
|
+
const vertex_1 = require("./vertex");
|
|
19
19
|
/**
|
|
20
20
|
* This is the underlying function to calculate the difference based on a given context.
|
|
21
21
|
* Use {@link Dataflow.diff} to calculate the diff of two graphs.
|
|
@@ -135,8 +135,8 @@ function diffVertices(ctx) {
|
|
|
135
135
|
position: `${ctx.position}Vertex ${id} differs in environment. `
|
|
136
136
|
});
|
|
137
137
|
}
|
|
138
|
-
if (
|
|
139
|
-
if (
|
|
138
|
+
if (vertex_1.FunctionCallVertex.is(lInfo)) {
|
|
139
|
+
if (!vertex_1.FunctionCallVertex.is(rInfo)) {
|
|
140
140
|
ctx.report.addComment(`Vertex ${id} differs in tags. ${ctx.leftname}: ${lInfo.tag} vs. ${ctx.rightname}: ${rInfo.tag}`);
|
|
141
141
|
}
|
|
142
142
|
else {
|
|
@@ -152,8 +152,8 @@ function diffVertices(ctx) {
|
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
|
-
if (
|
|
156
|
-
if (
|
|
155
|
+
if (vertex_1.FunctionDefinitionVertex.is(lInfo)) {
|
|
156
|
+
if (!vertex_1.FunctionDefinitionVertex.is(rInfo)) {
|
|
157
157
|
ctx.report.addComment(`Vertex ${id} differs in tags. ${ctx.leftname}: ${lInfo.tag} vs. ${ctx.rightname}: ${rInfo.tag}`, { tag: 'vertex', id });
|
|
158
158
|
}
|
|
159
159
|
else {
|
|
@@ -280,7 +280,7 @@ function diffEdge(edge, otherEdge, ctx, id, target) {
|
|
|
280
280
|
if ((edgeTypes.length < otherEdgeTypes.length && !ctx.config.leftIsSubgraph) || (edgeTypes.length > otherEdgeTypes.length && !ctx.config.rightIsSubgraph)) {
|
|
281
281
|
ctx.report.addComment(`Target of ${id}->${target} in ${ctx.leftname} differs in number of edge types: ${JSON.stringify([...edgeTypes])} vs ${JSON.stringify([...otherEdgeTypes])}`, { tag: 'edge', from: id, to: target });
|
|
282
282
|
}
|
|
283
|
-
if (edge
|
|
283
|
+
if (!edge_1.DfEdge.isOnlyType(edge, otherEdge.types)) {
|
|
284
284
|
ctx.report.addComment(`Target of ${id}->${target} in ${ctx.leftname} differs in edge types: ${JSON.stringify([...edge_1.DfEdge.typesToNames(edge)])} vs ${JSON.stringify([...edge_1.DfEdge.typesToNames(otherEdge)])}`, { tag: 'edge', from: id, to: target });
|
|
285
285
|
}
|
|
286
286
|
}
|
package/dataflow/graph/edge.d.ts
CHANGED
|
@@ -96,6 +96,33 @@ export declare const DfEdge: {
|
|
|
96
96
|
* Counterpart of {@link DfEdge#includesType}.
|
|
97
97
|
*/
|
|
98
98
|
readonly doesNotIncludeType: (this: void, { types }: DfEdgeLike, any: EdgeType) => boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Whether the edge carries any type at all.
|
|
101
|
+
* Counterpart of {@link DfEdge#hasNoType}.
|
|
102
|
+
* @example
|
|
103
|
+
*
|
|
104
|
+
* ```ts
|
|
105
|
+
* DfEdge.hasAnyType({ types: EdgeType.Reads }) // true
|
|
106
|
+
* DfEdge.hasAnyType({ types: 0 }) // false
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
readonly hasAnyType: (this: void, { types }: DfEdgeLike) => boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Whether the edge carries no type at all. Such an edge states nothing and has to be removed, not kept.
|
|
112
|
+
* Counterpart of {@link DfEdge#hasAnyType}.
|
|
113
|
+
*/
|
|
114
|
+
readonly hasNoType: (this: void, { types }: DfEdgeLike) => boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Check whether the edge carries the given types and nothing else.
|
|
117
|
+
* Strict counterpart of {@link DfEdge#includesType}, which already holds if one of the bits is set.
|
|
118
|
+
* @example
|
|
119
|
+
*
|
|
120
|
+
* ```ts
|
|
121
|
+
* DfEdge.isOnlyType({ types: EdgeType.Reads | EdgeType.Calls }, EdgeType.Reads) // false
|
|
122
|
+
* DfEdge.isOnlyType({ types: EdgeType.Reads | EdgeType.Calls }, EdgeType.Reads | EdgeType.Calls) // true
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
readonly isOnlyType: (this: void, { types }: DfEdgeLike, only: EdgeType) => boolean;
|
|
99
126
|
};
|
|
100
127
|
export declare const enum TraverseEdge {
|
|
101
128
|
/** Do not traverse this edge */
|
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,12 +9,12 @@ 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: {
|
|
17
|
+
readonly name: "GraphHelper";
|
|
18
18
|
/** Maps to the mermaid-centric visualization helper for dataflow graphs and their views */
|
|
19
19
|
readonly visualize: {
|
|
20
20
|
/**
|
|
@@ -11,12 +11,12 @@ 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 = {
|
|
19
|
+
name: 'GraphHelper',
|
|
20
20
|
/** Maps to the mermaid-centric visualization helper for dataflow graphs and their views */
|
|
21
21
|
visualize: {
|
|
22
22
|
/**
|
|
@@ -114,7 +114,7 @@ exports.GraphHelper = {
|
|
|
114
114
|
return true;
|
|
115
115
|
}
|
|
116
116
|
visited.add(currentId);
|
|
117
|
-
for (const [tar] of graph.outgoingEdges(currentId) ??
|
|
117
|
+
for (const [tar] of graph.outgoingEdges(currentId) ?? graph_1.NoEdges) {
|
|
118
118
|
toVisit.push(tar);
|
|
119
119
|
}
|
|
120
120
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
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';
|
|
@@ -141,6 +142,15 @@ 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
|
+
* The shared answer for a vertex without edges. Use it instead of a fresh `[]` fallback, the lookups sit in
|
|
147
|
+
* traversal loops where a miss is the common case.
|
|
148
|
+
* @example
|
|
149
|
+
* ```ts
|
|
150
|
+
* for(const [target, edge] of graph.outgoingEdges(id) ?? NoEdges) { /* ... *\/ }
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
export declare const NoEdges: ReadonlyMap<NodeId, never>;
|
|
144
154
|
/**
|
|
145
155
|
* The structure of the serialized {@link DataflowGraph}.
|
|
146
156
|
*/
|
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`
|
|
@@ -340,7 +351,7 @@ class DataflowGraph {
|
|
|
340
351
|
return this;
|
|
341
352
|
}
|
|
342
353
|
edge.types &= ~type;
|
|
343
|
-
if (edge
|
|
354
|
+
if (edge_1.DfEdge.hasAnyType(edge)) {
|
|
344
355
|
/* the reverse index holds this very object, so a narrowed type is already visible through it */
|
|
345
356
|
return this;
|
|
346
357
|
}
|
|
@@ -488,7 +499,7 @@ class DataflowGraph {
|
|
|
488
499
|
setDefinitionOfVertex(reference, sourceIds) {
|
|
489
500
|
const vertex = this.getVertex(reference.nodeId);
|
|
490
501
|
(0, assert_1.guard)(vertex !== undefined, () => `node must be defined for ${JSON.stringify(reference)} to set reference`);
|
|
491
|
-
if (
|
|
502
|
+
if (vertex_2.FunctionDefinitionVertex.is(vertex) || vertex_2.VariableDefinitionVertex.is(vertex)) {
|
|
492
503
|
vertex.cds = reference.cds;
|
|
493
504
|
}
|
|
494
505
|
else {
|
|
@@ -520,7 +531,7 @@ class DataflowGraph {
|
|
|
520
531
|
updateToFunctionCall(info) {
|
|
521
532
|
const infoId = info.id;
|
|
522
533
|
const vertex = this.getVertex(infoId);
|
|
523
|
-
(0, assert_1.guard)(vertex !== undefined && (
|
|
534
|
+
(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
535
|
const previousTag = vertex.tag;
|
|
525
536
|
this.vertexInformation.set(infoId, { ...vertex, ...info, tag: vertex_1.VertexType.FunctionCall });
|
|
526
537
|
const prevIds = this.types.get(previousTag);
|
|
@@ -594,7 +605,7 @@ function mergeNodeInfos(current, next) {
|
|
|
594
605
|
if (current.tag !== next.tag) {
|
|
595
606
|
return current;
|
|
596
607
|
}
|
|
597
|
-
else if (
|
|
608
|
+
else if (vertex_2.FunctionDefinitionVertex.is(current)) {
|
|
598
609
|
const n = next;
|
|
599
610
|
current.exitPoints = (0, arrays_1.uniqueArrayMerge)(current.exitPoints, n.exitPoints);
|
|
600
611
|
if (n.mode && n.mode.length > 0) {
|
|
@@ -176,30 +176,71 @@ 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: {
|
|
187
|
+
name: string;
|
|
181
188
|
/** Whether the given vertex is a value vertex. */
|
|
182
189
|
is(this: void, vertex?: DataflowGraphVertexBase): vertex is DataflowGraphVertexValue;
|
|
183
190
|
};
|
|
184
|
-
/**
|
|
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
|
+
*/
|
|
185
198
|
export declare const UseVertex: {
|
|
199
|
+
name: string;
|
|
186
200
|
/** Whether the given vertex is a use vertex. */
|
|
187
201
|
is(this: void, vertex?: DataflowGraphVertexBase): vertex is DataflowGraphVertexUse;
|
|
188
202
|
};
|
|
189
|
-
/**
|
|
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
|
+
*/
|
|
190
212
|
export declare const FunctionCallVertex: {
|
|
213
|
+
name: string;
|
|
191
214
|
/** Whether the given vertex is a function call vertex. */
|
|
192
215
|
is(this: void, vertex?: DataflowGraphVertexBase): vertex is DataflowGraphVertexFunctionCall;
|
|
193
|
-
/**
|
|
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
|
+
*/
|
|
194
220
|
hasOrigin(this: void, vertex: DataflowGraphVertexBase | undefined, origin: BuiltInProcName): boolean;
|
|
195
221
|
};
|
|
196
|
-
/**
|
|
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
|
+
*/
|
|
197
229
|
export declare const VariableDefinitionVertex: {
|
|
230
|
+
name: string;
|
|
198
231
|
/** Whether the given vertex is a variable definition vertex. */
|
|
199
232
|
is(this: void, vertex?: DataflowGraphVertexBase): vertex is DataflowGraphVertexVariableDefinition;
|
|
200
233
|
};
|
|
201
|
-
/**
|
|
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
|
+
*/
|
|
202
242
|
export declare const FunctionDefinitionVertex: {
|
|
243
|
+
name: string;
|
|
203
244
|
/** Whether the given vertex is a function definition vertex. */
|
|
204
245
|
is(this: void, vertex?: DataflowGraphVertexBase): vertex is DataflowGraphVertexFunctionDefinition;
|
|
205
246
|
};
|
package/dataflow/graph/vertex.js
CHANGED
|
@@ -11,40 +11,81 @@ 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 = {
|
|
22
|
+
name: 'ValueVertex',
|
|
16
23
|
/** Whether the given vertex is a value vertex. */
|
|
17
24
|
is(vertex) {
|
|
18
25
|
return vertex?.tag === VertexType.Value;
|
|
19
26
|
}
|
|
20
27
|
};
|
|
21
|
-
/**
|
|
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
|
+
*/
|
|
22
35
|
exports.UseVertex = {
|
|
36
|
+
name: 'UseVertex',
|
|
23
37
|
/** Whether the given vertex is a use vertex. */
|
|
24
38
|
is(vertex) {
|
|
25
39
|
return vertex?.tag === VertexType.Use;
|
|
26
40
|
}
|
|
27
41
|
};
|
|
28
|
-
/**
|
|
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
|
+
*/
|
|
29
51
|
exports.FunctionCallVertex = {
|
|
52
|
+
name: 'FunctionCallVertex',
|
|
30
53
|
/** Whether the given vertex is a function call vertex. */
|
|
31
54
|
is(vertex) {
|
|
32
55
|
return vertex?.tag === VertexType.FunctionCall;
|
|
33
56
|
},
|
|
34
|
-
/**
|
|
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
|
+
*/
|
|
35
61
|
hasOrigin(vertex, origin) {
|
|
36
62
|
return exports.FunctionCallVertex.is(vertex) && vertex.origin.includes(origin);
|
|
37
63
|
}
|
|
38
64
|
};
|
|
39
|
-
/**
|
|
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
|
+
*/
|
|
40
72
|
exports.VariableDefinitionVertex = {
|
|
73
|
+
name: 'VariableDefinitionVertex',
|
|
41
74
|
/** Whether the given vertex is a variable definition vertex. */
|
|
42
75
|
is(vertex) {
|
|
43
76
|
return vertex?.tag === VertexType.VariableDefinition;
|
|
44
77
|
}
|
|
45
78
|
};
|
|
46
|
-
/**
|
|
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
|
+
*/
|
|
47
87
|
exports.FunctionDefinitionVertex = {
|
|
88
|
+
name: 'FunctionDefinitionVertex',
|
|
48
89
|
/** Whether the given vertex is a function definition vertex. */
|
|
49
90
|
is(vertex) {
|
|
50
91
|
return vertex?.tag === VertexType.FunctionDefinition;
|