@eagleoutice/flowr 2.13.14 → 2.13.16
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 +25 -31
- package/abstract-interpretation/data-frame/resolve-args.js +11 -12
- package/abstract-interpretation/unsupported-functions.d.ts +1 -0
- package/abstract-interpretation/unsupported-functions.js +1 -0
- package/benchmark/summarizer/second-phase/graph.d.ts +23 -0
- package/benchmark/summarizer/second-phase/graph.js +47 -14
- package/cli/repl/commands/repl-cfg.js +2 -42
- package/cli/repl/commands/repl-clipboard.d.ts +7 -0
- package/cli/repl/commands/repl-clipboard.js +53 -0
- package/cli/repl/commands/repl-dataflow.js +5 -70
- package/cli/repl/commands/repl-normalize.js +3 -51
- package/cli/repl/commands/repl-query.js +37 -2
- package/cli/repl/core.js +5 -2
- package/control-flow/cfg-dead-code.js +5 -29
- package/control-flow/control-flow-graph.d.ts +2 -0
- package/control-flow/control-flow-graph.js +2 -0
- package/control-flow/diff-cfg.js +2 -56
- package/control-flow/semantic-cfg-guided-visitor.d.ts +7 -0
- package/control-flow/semantic-cfg-guided-visitor.js +14 -0
- package/control-flow/useless-loop.js +4 -26
- package/core/steps/all/core/10-normalize.d.ts +8 -0
- package/core/steps/all/core/10-normalize.js +10 -8
- package/core/steps/all/core/11-normalize-tree-sitter.d.ts +5 -7
- package/core/steps/all/core/11-normalize-tree-sitter.js +2 -9
- package/data/r-base-packages.generated.d.ts +1 -0
- package/data/r-base-packages.generated.js +5 -3
- package/dataflow/environments/built-in-config.d.ts +9 -1
- package/dataflow/environments/built-in-proc-name.d.ts +2 -0
- package/dataflow/environments/built-in-proc-name.js +2 -0
- package/dataflow/environments/built-in-props.d.ts +4 -0
- package/dataflow/environments/built-in-props.js +3 -3
- package/dataflow/environments/built-in.d.ts +4 -2
- package/dataflow/environments/built-in.js +53 -3
- package/dataflow/environments/data-masking-functions.d.ts +3 -4
- package/dataflow/environments/data-masking-functions.js +7 -8
- package/dataflow/environments/default-builtin-config.d.ts +92 -12
- package/dataflow/environments/default-builtin-config.js +86 -43
- package/dataflow/environments/environment.d.ts +5 -0
- package/dataflow/environments/environment.js +17 -12
- package/dataflow/environments/identifier.d.ts +3 -0
- package/dataflow/eval/resolve/alias-tracking.js +4 -7
- package/dataflow/eval/resolve/node-value.d.ts +51 -0
- package/dataflow/eval/resolve/node-value.js +71 -0
- package/dataflow/eval/resolve/resolve-argument.js +10 -7
- package/dataflow/eval/resolve/resolve-operators.js +1 -2
- package/dataflow/eval/values/general.d.ts +4 -0
- package/dataflow/eval/values/general.js +14 -0
- package/dataflow/eval/values/r-value.d.ts +15 -0
- package/dataflow/eval/values/r-value.js +27 -1
- package/dataflow/extractor.js +2 -0
- package/dataflow/fn/higher-order-function.d.ts +1 -1
- package/dataflow/fn/higher-order-function.js +22 -4
- package/dataflow/graph/call-graph.d.ts +1 -1
- package/dataflow/graph/call-graph.js +1 -1
- package/dataflow/graph/df-helper.d.ts +2 -2
- package/dataflow/graph/df-helper.js +1 -1
- package/dataflow/graph/diff-dataflow-graph.js +3 -55
- package/dataflow/graph/graph-helper.d.ts +1 -0
- package/dataflow/graph/graph-helper.js +1 -0
- package/dataflow/graph/graph.d.ts +5 -0
- package/dataflow/graph/graph.js +27 -0
- package/dataflow/graph/vertex.d.ts +5 -0
- package/dataflow/graph/vertex.js +5 -0
- package/dataflow/internal/linker.d.ts +23 -0
- package/dataflow/internal/linker.js +70 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +4 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +2 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +8 -29
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +39 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +10 -22
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +29 -53
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +4 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +7 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-load.js +2 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +19 -12
- package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +3 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +69 -52
- package/dataflow/internal/process/functions/call/built-in/built-in-recall.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.js +2 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +2 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +6 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +31 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.d.ts +5 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +7 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +6 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +20 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-stop-if-not.js +6 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-string-template.d.ts +25 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-string-template.js +105 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +1 -27
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +4 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +1 -1
- package/dataflow/internal/process/functions/call/deferred.d.ts +48 -0
- package/dataflow/internal/process/functions/call/deferred.js +149 -0
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +13 -12
- package/dataflow/internal/process/functions/call/known-call-handling.js +35 -35
- package/dataflow/internal/process/functions/call/named-call-handling.d.ts +1 -1
- package/dataflow/internal/process/functions/call/named-call-handling.js +8 -4
- package/dataflow/internal/process/functions/call/nse.d.ts +29 -0
- package/dataflow/internal/process/functions/call/nse.js +88 -0
- package/dataflow/internal/process/functions/call/quoted.d.ts +30 -0
- package/dataflow/internal/process/functions/call/quoted.js +191 -0
- package/documentation/doc-util/doc-types.js +15 -9
- package/documentation/wiki-dataflow-graph.js +8 -0
- package/linter/linter-format.d.ts +1 -0
- package/linter/linter-format.js +1 -0
- package/linter/rules/deprecated-functions.js +9 -3
- package/linter/rules/seeded-randomness.js +2 -3
- package/linter/rules/undefined-symbol.js +10 -1
- package/package.json +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.d.ts +6 -0
- package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.js +17 -1
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.d.ts +2 -11
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.js +3 -15
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmarkdown-file-plugin.d.ts +16 -0
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmarkdown-file-plugin.js +26 -0
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.d.ts +2 -11
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.js +3 -15
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-description-file-plugin.js +4 -10
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.js +2 -9
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +2 -9
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +1 -1
- package/project/sigdb/reader.d.ts +9 -0
- package/project/sigdb/reader.js +30 -0
- package/queries/catalog/absint-query/absint-query-format.js +1 -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 +2 -2
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.d.ts +0 -12
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +2 -37
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +1 -1
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +2 -23
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +1 -1
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.js +2 -2
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +1 -1
- package/queries/catalog/location-map-query/location-map-query-format.js +1 -1
- 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-format.js +1 -1
- package/queries/query-function-filter.d.ts +21 -0
- package/queries/query-function-filter.js +48 -0
- package/r-bridge/data/data.d.ts +13 -3
- package/r-bridge/data/data.js +15 -3
- 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/nodes/r-function-call.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +4 -0
- package/search/flowr-search-filters.d.ts +5 -1
- package/search/flowr-search-filters.js +31 -21
- package/search/search-executor/search-enrichers.d.ts +24 -4
- package/search/search-executor/search-enrichers.js +22 -9
- package/search/search-executor/search-transformer.js +1 -1
- package/slicing/criterion/parse.d.ts +1 -0
- package/slicing/criterion/parse.js +1 -0
- package/util/diff-graph.d.ts +13 -0
- package/util/diff-graph.js +64 -1
- package/util/files.js +9 -8
- package/util/r-base-packages.d.ts +2 -0
- package/util/r-base-packages.js +3 -1
- 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/version.js +1 -1
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
2
|
+
import type { ParentInformation, RNodeWithParent } from '../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
3
|
+
import type { DataflowProcessorInformation } from '../../processor';
|
|
4
|
+
import type { DataflowGraph } from '../../graph/graph';
|
|
5
|
+
import type { ReadOnlyFlowrAnalyzerContext } from '../../../project/context/flowr-analyzer-context';
|
|
6
|
+
import type { ResolveInfo, ResolveResult } from './alias-tracking';
|
|
7
|
+
import { soleValue } from '../values/general';
|
|
8
|
+
import type { Value, ValueSet } from '../values/r-value';
|
|
9
|
+
/** The node to resolve, given either by id or directly. */
|
|
10
|
+
type Target = NodeId | RNodeWithParent | undefined;
|
|
11
|
+
declare function infoOf<OtherInfo>(this: void, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, overrides?: Partial<ResolveInfo>): ResolveInfo;
|
|
12
|
+
/**
|
|
13
|
+
* The value(s) a node may hold, resolved against the state the current processor sees.
|
|
14
|
+
* Use {@link NodeValue.inGraph} to resolve against a finished {@link DataflowGraph} instead.
|
|
15
|
+
* Every entry point accepts overrides for the cases that deviate (e.g. another environment).
|
|
16
|
+
*
|
|
17
|
+
* This is constant propagation over the dataflow graph, not abstract interpretation: it follows definitions to
|
|
18
|
+
* constants and gives up wherever a value is not statically pinned down, with no fixpoint and no widening.
|
|
19
|
+
* Anything needing an abstract state lives in `src/abstract-interpretation/`.
|
|
20
|
+
*/
|
|
21
|
+
export declare const NodeValue: {
|
|
22
|
+
readonly name: "NodeValue";
|
|
23
|
+
/** The resolve info the processor's state stands for, for repeated resolutions. */
|
|
24
|
+
readonly infoOf: typeof infoOf;
|
|
25
|
+
/** The value(s) the node may hold. */
|
|
26
|
+
readonly of: <OtherInfo>(this: void, id: Target, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, overrides?: Partial<ResolveInfo>) => ResolveResult;
|
|
27
|
+
/** The value set the node may hold, `undefined` if it resolves to top or bottom. */
|
|
28
|
+
readonly setOf: <OtherInfo>(this: void, id: Target, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, overrides?: Partial<ResolveInfo>) => ValueSet<Value[]> | undefined;
|
|
29
|
+
/** The strings the node may hold, `undefined` if it does not resolve to strings. */
|
|
30
|
+
readonly stringsOf: <OtherInfo>(this: void, id: Target, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, overrides?: Partial<ResolveInfo>) => string[] | undefined;
|
|
31
|
+
/** The single string the node resolves to, `undefined` if it is not exactly one. */
|
|
32
|
+
readonly singleStringOf: <OtherInfo>(this: void, id: Target, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, overrides?: Partial<ResolveInfo>) => string | undefined;
|
|
33
|
+
/** The one value a set holds, `undefined` unless it holds exactly one, optionally of the given kind. */
|
|
34
|
+
readonly sole: typeof soleValue;
|
|
35
|
+
/** The one value the node resolves to, `undefined` unless it is exactly one, optionally of the given kind. */
|
|
36
|
+
readonly soleOf: <OtherInfo, T extends Value["type"]>(this: void, id: Target, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, type?: T, overrides?: Partial<ResolveInfo>) => Extract<Value, {
|
|
37
|
+
type: T;
|
|
38
|
+
}> | undefined;
|
|
39
|
+
/** The same questions, asked of a finished dataflow graph instead of a running processor. */
|
|
40
|
+
readonly inGraph: {
|
|
41
|
+
/** The value set the node may hold, `undefined` if it resolves to top or bottom. */
|
|
42
|
+
readonly setOf: (this: void, id: Target, graph: DataflowGraph, ctx: ReadOnlyFlowrAnalyzerContext, overrides?: Partial<ResolveInfo>) => ValueSet<Value[]> | undefined;
|
|
43
|
+
/** The single string the node resolves to, `undefined` if it is not exactly one. */
|
|
44
|
+
readonly singleStringOf: (this: void, id: Target, graph: DataflowGraph, ctx: ReadOnlyFlowrAnalyzerContext, overrides?: Partial<ResolveInfo>) => string | undefined;
|
|
45
|
+
/** The one value the node resolves to, `undefined` unless it is exactly one, optionally of the given kind. */
|
|
46
|
+
readonly soleOf: <T extends Value["type"]>(this: void, id: Target, graph: DataflowGraph, ctx: ReadOnlyFlowrAnalyzerContext, type?: T, overrides?: Partial<ResolveInfo>) => Extract<Value, {
|
|
47
|
+
type: T;
|
|
48
|
+
}> | undefined;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NodeValue = void 0;
|
|
4
|
+
const alias_tracking_1 = require("./alias-tracking");
|
|
5
|
+
const general_1 = require("../values/general");
|
|
6
|
+
const string_constants_1 = require("../values/string/string-constants");
|
|
7
|
+
function infoOf(data, overrides) {
|
|
8
|
+
return {
|
|
9
|
+
environment: data.environment,
|
|
10
|
+
idMap: data.completeAst.idMap,
|
|
11
|
+
resolve: data.ctx.config.solver.variables,
|
|
12
|
+
ctx: data.ctx,
|
|
13
|
+
...overrides
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function graphInfoOf(graph, ctx, overrides) {
|
|
17
|
+
return { graph, resolve: ctx.config.solver.variables, ctx, ...overrides };
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The value(s) a node may hold, resolved against the state the current processor sees.
|
|
21
|
+
* Use {@link NodeValue.inGraph} to resolve against a finished {@link DataflowGraph} instead.
|
|
22
|
+
* Every entry point accepts overrides for the cases that deviate (e.g. another environment).
|
|
23
|
+
*
|
|
24
|
+
* This is constant propagation over the dataflow graph, not abstract interpretation: it follows definitions to
|
|
25
|
+
* constants and gives up wherever a value is not statically pinned down, with no fixpoint and no widening.
|
|
26
|
+
* Anything needing an abstract state lives in `src/abstract-interpretation/`.
|
|
27
|
+
*/
|
|
28
|
+
exports.NodeValue = {
|
|
29
|
+
name: 'NodeValue',
|
|
30
|
+
/** The resolve info the processor's state stands for, for repeated resolutions. */
|
|
31
|
+
infoOf,
|
|
32
|
+
/** The value(s) the node may hold. */
|
|
33
|
+
of(id, data, overrides) {
|
|
34
|
+
return (0, alias_tracking_1.resolveIdToValue)(id, infoOf(data, overrides));
|
|
35
|
+
},
|
|
36
|
+
/** The value set the node may hold, `undefined` if it resolves to top or bottom. */
|
|
37
|
+
setOf(id, data, overrides) {
|
|
38
|
+
return (0, general_1.valueSetGuard)((0, alias_tracking_1.resolveIdToValue)(id, infoOf(data, overrides)));
|
|
39
|
+
},
|
|
40
|
+
/** The strings the node may hold, `undefined` if it does not resolve to strings. */
|
|
41
|
+
stringsOf(id, data, overrides) {
|
|
42
|
+
const resolved = (0, general_1.valueSetGuard)((0, alias_tracking_1.resolveIdToValue)(id, infoOf(data, overrides)));
|
|
43
|
+
return resolved ? (0, string_constants_1.collectStrings)(resolved.elements) : undefined;
|
|
44
|
+
},
|
|
45
|
+
/** The single string the node resolves to, `undefined` if it is not exactly one. */
|
|
46
|
+
singleStringOf(id, data, overrides) {
|
|
47
|
+
return (0, alias_tracking_1.resolveIdToSingleString)(id, infoOf(data, overrides));
|
|
48
|
+
},
|
|
49
|
+
/** The one value a set holds, `undefined` unless it holds exactly one, optionally of the given kind. */
|
|
50
|
+
sole: general_1.soleValue,
|
|
51
|
+
/** The one value the node resolves to, `undefined` unless it is exactly one, optionally of the given kind. */
|
|
52
|
+
soleOf(id, data, type, overrides) {
|
|
53
|
+
return (0, general_1.soleValue)((0, general_1.valueSetGuard)((0, alias_tracking_1.resolveIdToValue)(id, infoOf(data, overrides))), type);
|
|
54
|
+
},
|
|
55
|
+
/** The same questions, asked of a finished dataflow graph instead of a running processor. */
|
|
56
|
+
inGraph: {
|
|
57
|
+
/** The value set the node may hold, `undefined` if it resolves to top or bottom. */
|
|
58
|
+
setOf(id, graph, ctx, overrides) {
|
|
59
|
+
return (0, general_1.valueSetGuard)((0, alias_tracking_1.resolveIdToValue)(id, graphInfoOf(graph, ctx, overrides)));
|
|
60
|
+
},
|
|
61
|
+
/** The single string the node resolves to, `undefined` if it is not exactly one. */
|
|
62
|
+
singleStringOf(id, graph, ctx, overrides) {
|
|
63
|
+
return (0, alias_tracking_1.resolveIdToSingleString)(id, graphInfoOf(graph, ctx, overrides));
|
|
64
|
+
},
|
|
65
|
+
/** The one value the node resolves to, `undefined` unless it is exactly one, optionally of the given kind. */
|
|
66
|
+
soleOf(id, graph, ctx, type, overrides) {
|
|
67
|
+
return (0, general_1.soleValue)((0, general_1.valueSetGuard)((0, alias_tracking_1.resolveIdToValue)(id, graphInfoOf(graph, ctx, overrides))), type);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=node-value.js.map
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getArgumentStringValue = getArgumentStringValue;
|
|
4
4
|
const graph_1 = require("../../graph/graph");
|
|
5
|
+
const r_value_1 = require("../values/r-value");
|
|
5
6
|
const r_function_call_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
6
7
|
const assert_1 = require("../../../util/assert");
|
|
7
8
|
const type_1 = require("../../../r-bridge/lang-4.x/ast/model/type");
|
|
8
9
|
const dependencies_query_format_1 = require("../../../queries/catalog/dependencies-query/dependencies-query-format");
|
|
9
10
|
const general_1 = require("../values/general");
|
|
10
11
|
const alias_tracking_1 = require("./alias-tracking");
|
|
11
|
-
const
|
|
12
|
+
const r_value_2 = require("../values/r-value");
|
|
12
13
|
const convert_values_1 = require("../../../r-bridge/lang-4.x/convert-values");
|
|
13
14
|
const string_constants_1 = require("../values/string/string-constants");
|
|
14
15
|
/**
|
|
@@ -92,7 +93,7 @@ function resolveBasedOnConfig(variableResolve, graph, vertex, argument, environm
|
|
|
92
93
|
if (resolved) {
|
|
93
94
|
const values = [];
|
|
94
95
|
for (const value of resolved.elements) {
|
|
95
|
-
const strings = (0,
|
|
96
|
+
const strings = (0, r_value_2.isValue)(value) ? stringsOfValue(value, full) : undefined;
|
|
96
97
|
if (strings === undefined) {
|
|
97
98
|
return undefined;
|
|
98
99
|
}
|
|
@@ -107,13 +108,15 @@ function resolveBasedOnConfig(variableResolve, graph, vertex, argument, environm
|
|
|
107
108
|
*/
|
|
108
109
|
function stringsOfValue(value, full) {
|
|
109
110
|
switch (value.type) {
|
|
110
|
-
case 'string':
|
|
111
|
-
|
|
111
|
+
case 'string': {
|
|
112
|
+
const str = r_value_1.RValue.stringOf(value);
|
|
113
|
+
return str !== undefined ? [str] : undefined;
|
|
114
|
+
}
|
|
112
115
|
case 'logical':
|
|
113
|
-
return (0,
|
|
116
|
+
return (0, r_value_2.isValue)(value.value) ? [value.value.valueOf() ? convert_values_1.RTrue : convert_values_1.RFalse] : undefined;
|
|
114
117
|
case 'vector':
|
|
115
|
-
return (0,
|
|
116
|
-
? (0, string_constants_1.collectStrings)(value.elements, !full) ?? (value.elements.every(
|
|
118
|
+
return (0, r_value_2.isValue)(value.elements)
|
|
119
|
+
? (0, string_constants_1.collectStrings)(value.elements, !full) ?? (value.elements.every(r_value_2.isValue) ? [dependencies_query_format_1.Constant] : undefined)
|
|
117
120
|
: undefined;
|
|
118
121
|
case 'number':
|
|
119
122
|
case 'interval':
|
|
@@ -109,7 +109,6 @@ function resolveAsGroup(args) {
|
|
|
109
109
|
return r_value_2.Top;
|
|
110
110
|
}
|
|
111
111
|
/* unwrap the set again, as the caller of a handler wraps the returned value in one */
|
|
112
|
-
|
|
113
|
-
return values?.elements.length === 1 ? values.elements[0] : r_value_2.Top;
|
|
112
|
+
return (0, general_1.soleValue)((0, general_1.valueSetGuard)((0, alias_tracking_1.resolveIdToValue)(node.children[0], args))) ?? r_value_2.Top;
|
|
114
113
|
}
|
|
115
114
|
//# sourceMappingURL=resolve-operators.js.map
|
|
@@ -11,6 +11,10 @@ export declare function bottomTopGuard(...a: Lift<unknown>[]): typeof Top | type
|
|
|
11
11
|
* @returns value set if a is not top or bottom
|
|
12
12
|
*/
|
|
13
13
|
export declare function valueSetGuard(a: Lift<ValueSet<Value[]>>): ValueSet<Value[]> | undefined;
|
|
14
|
+
export declare function soleValue(this: void, set: ValueSet<Value[]> | undefined): Value | undefined;
|
|
15
|
+
export declare function soleValue<T extends Value['type']>(this: void, set: ValueSet<Value[]> | undefined, type: T): Extract<Value, {
|
|
16
|
+
type: T;
|
|
17
|
+
}> | undefined;
|
|
14
18
|
/**
|
|
15
19
|
* Constructs an Abstract Value from a normal TS value
|
|
16
20
|
* @param a - ts value
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.bottomTopGuard = bottomTopGuard;
|
|
4
4
|
exports.valueSetGuard = valueSetGuard;
|
|
5
|
+
exports.soleValue = soleValue;
|
|
5
6
|
exports.valueFromTsValue = valueFromTsValue;
|
|
6
7
|
exports.valueFromRNodeConstant = valueFromRNodeConstant;
|
|
7
8
|
const type_1 = require("../../../r-bridge/lang-4.x/ast/model/type");
|
|
@@ -30,6 +31,16 @@ function bottomTopGuard(...a) {
|
|
|
30
31
|
function valueSetGuard(a) {
|
|
31
32
|
return ((0, r_value_1.isBottom)(a) || (0, r_value_1.isTop)(a)) ? undefined : a;
|
|
32
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* The one value a set holds, `undefined` unless it holds exactly one, optionally of the given kind.
|
|
36
|
+
* @param set - the set to take the value from
|
|
37
|
+
* @param type - the kind the value has to have, any kind if unset
|
|
38
|
+
* @returns the sole value, `undefined` if the set holds another number of them or another kind
|
|
39
|
+
*/
|
|
40
|
+
function soleValue(set, type) {
|
|
41
|
+
const only = set?.elements.length === 1 ? set.elements[0] : undefined;
|
|
42
|
+
return only !== undefined && (type === undefined || only.type === type) ? only : undefined;
|
|
43
|
+
}
|
|
33
44
|
/**
|
|
34
45
|
* Constructs an Abstract Value from a normal TS value
|
|
35
46
|
* @param a - ts value
|
|
@@ -71,6 +82,9 @@ function valueFromRNodeConstant(a) {
|
|
|
71
82
|
else if (a.type === type_1.RType.Logical) {
|
|
72
83
|
return a.content.valueOf() ? logical_constants_1.ValueLogicalTrue : logical_constants_1.ValueLogicalFalse;
|
|
73
84
|
}
|
|
85
|
+
else if (a.type === type_1.RType.FunctionDefinition) {
|
|
86
|
+
return { type: 'function-definition' };
|
|
87
|
+
}
|
|
74
88
|
return r_value_1.Top;
|
|
75
89
|
}
|
|
76
90
|
//# sourceMappingURL=general.js.map
|
|
@@ -74,3 +74,18 @@ export declare function asValue<V extends Lift<unknown>>(value: V): Unlift<V>;
|
|
|
74
74
|
*
|
|
75
75
|
*/
|
|
76
76
|
export declare function stringifyValue(value: Lift<Value>): string;
|
|
77
|
+
/**
|
|
78
|
+
* Reads the plain TS value a {@link Value} stands for, `undefined` whenever it stands for more than one, for
|
|
79
|
+
* none, or for another kind. Prefer these over reaching into a value's shape by hand.
|
|
80
|
+
*
|
|
81
|
+
* This is the constant-folding view: it answers "is this one known constant" and nothing else. It runs no
|
|
82
|
+
* fixpoint, knows no control flow, and widens nothing. For an abstract state that does, use the dedicated
|
|
83
|
+
* abstract interpretation in `src/abstract-interpretation/`.
|
|
84
|
+
*/
|
|
85
|
+
export declare const RValue: {
|
|
86
|
+
readonly name: "RValue";
|
|
87
|
+
/** The number the value stands for, collapsing an interval that admits a single one. */
|
|
88
|
+
readonly numberOf: (this: void, value: Value) => number | undefined;
|
|
89
|
+
/** The string the value stands for. */
|
|
90
|
+
readonly stringOf: (this: void, value: Value) => string | undefined;
|
|
91
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Bottom = exports.Top = void 0;
|
|
3
|
+
exports.RValue = exports.Bottom = exports.Top = void 0;
|
|
4
4
|
exports.typeOfValue = typeOfValue;
|
|
5
5
|
exports.isTop = isTop;
|
|
6
6
|
exports.isBottom = isBottom;
|
|
@@ -103,4 +103,30 @@ function stringifyValue(value) {
|
|
|
103
103
|
}
|
|
104
104
|
});
|
|
105
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Reads the plain TS value a {@link Value} stands for, `undefined` whenever it stands for more than one, for
|
|
108
|
+
* none, or for another kind. Prefer these over reaching into a value's shape by hand.
|
|
109
|
+
*
|
|
110
|
+
* This is the constant-folding view: it answers "is this one known constant" and nothing else. It runs no
|
|
111
|
+
* fixpoint, knows no control flow, and widens nothing. For an abstract state that does, use the dedicated
|
|
112
|
+
* abstract interpretation in `src/abstract-interpretation/`.
|
|
113
|
+
*/
|
|
114
|
+
exports.RValue = {
|
|
115
|
+
name: 'RValue',
|
|
116
|
+
/** The number the value stands for, collapsing an interval that admits a single one. */
|
|
117
|
+
numberOf(value) {
|
|
118
|
+
if (value.type === 'number') {
|
|
119
|
+
return isValue(value.value) && !value.value.complexNumber ? value.value.num : undefined;
|
|
120
|
+
}
|
|
121
|
+
else if (value.type === 'interval' && value.startInclusive && value.endInclusive) {
|
|
122
|
+
const start = exports.RValue.numberOf(value.start);
|
|
123
|
+
return start !== undefined && start === exports.RValue.numberOf(value.end) ? start : undefined;
|
|
124
|
+
}
|
|
125
|
+
return undefined;
|
|
126
|
+
},
|
|
127
|
+
/** The string the value stands for. */
|
|
128
|
+
stringOf(value) {
|
|
129
|
+
return value.type === 'string' && isValue(value.value) ? value.value.str : undefined;
|
|
130
|
+
}
|
|
131
|
+
};
|
|
106
132
|
//# sourceMappingURL=r-value.js.map
|
package/dataflow/extractor.js
CHANGED
|
@@ -25,6 +25,7 @@ const flowr_file_1 = require("../project/context/flowr-file");
|
|
|
25
25
|
/** Round cap for the transitive-side-effect fixpoint. */
|
|
26
26
|
const transitiveSideEffectRounds = 32;
|
|
27
27
|
const identifier_1 = require("./environments/identifier");
|
|
28
|
+
const quoted_1 = require("./internal/process/functions/call/quoted");
|
|
28
29
|
const range_1 = require("../util/range");
|
|
29
30
|
const logger_1 = require("./logger");
|
|
30
31
|
const gas_1 = require("../gas");
|
|
@@ -171,6 +172,7 @@ function produceDataFlowGraph(parser, completeAst, ctx) {
|
|
|
171
172
|
}
|
|
172
173
|
// link on-demand-materialized package exports back to their `library()` loaders
|
|
173
174
|
(0, transitive_side_effects_1.linkMaterializedExportsToLoaders)(df.graph, df.environment);
|
|
175
|
+
quoted_1.Quoted.finalize(df.graph, completeAst.idMap, () => (0, extract_cfg_1.extractCfgQuick)(completeAst).graph);
|
|
174
176
|
df.cfgQuick = resolveLinkToSideEffects(completeAst, df.graph, ctx);
|
|
175
177
|
// performance optimization: return cfgQuick as part of the result to avoid recomputation
|
|
176
178
|
return df;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
2
2
|
import type { DataflowGraph } from '../graph/graph';
|
|
3
3
|
import type { ReadOnlyFlowrAnalyzerContext } from '../../project/context/flowr-analyzer-context';
|
|
4
4
|
/**
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isFunctionHigherOrder = isFunctionHigherOrder;
|
|
4
|
+
const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
5
|
+
const resolve_by_name_1 = require("../environments/resolve-by-name");
|
|
6
|
+
const identifier_1 = require("../environments/identifier");
|
|
4
7
|
const vertex_1 = require("../graph/vertex");
|
|
5
8
|
const assert_1 = require("../../util/assert");
|
|
6
9
|
const edge_1 = require("../graph/edge");
|
|
7
|
-
const
|
|
10
|
+
const node_value_1 = require("../eval/resolve/node-value");
|
|
8
11
|
const config_1 = require("../../config");
|
|
9
12
|
const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
10
|
-
const general_1 = require("../eval/values/general");
|
|
11
13
|
function isAnyReturnAFunction(def, graph) {
|
|
12
14
|
const workingQueue = def.exitPoints.map(d => graph.getVertex(d.nodeId)).filter(assert_1.isNotUndefined);
|
|
13
15
|
const seen = new Set();
|
|
@@ -32,6 +34,22 @@ function isAnyReturnAFunction(def, graph) {
|
|
|
32
34
|
}
|
|
33
35
|
return false;
|
|
34
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Whether the argument hands over a built-in function (`f(print)`), which has no definition in the graph and
|
|
39
|
+
* hence no `function-definition` value to resolve to.
|
|
40
|
+
*/
|
|
41
|
+
function readsBuiltInFunction(id, graph, ctx) {
|
|
42
|
+
for (const [target, edge] of graph.outgoingEdges(id) ?? []) {
|
|
43
|
+
if (!edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Reads) || !node_id_1.NodeId.isBuiltIn(target)) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const defs = (0, resolve_by_name_1.resolveByName)(node_id_1.NodeId.fromBuiltIn(target), ctx.env.makeCleanEnv(), identifier_1.ReferenceType.Function);
|
|
47
|
+
if (defs?.some(d => (0, identifier_1.isReferenceType)(d.type, identifier_1.ReferenceType.BuiltInFunction))) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
35
53
|
function inspectCallSitesArgumentsFns(def, graph, ctx, invertedGraph) {
|
|
36
54
|
const callSites = invertedGraph?.outgoingEdges(def.id) ?? graph.ingoingEdges(def.id);
|
|
37
55
|
for (const [callerId, e] of callSites ?? []) {
|
|
@@ -46,8 +64,8 @@ function inspectCallSitesArgumentsFns(def, graph, ctx, invertedGraph) {
|
|
|
46
64
|
if (arg === r_function_call_1.EmptyArgument) {
|
|
47
65
|
continue;
|
|
48
66
|
}
|
|
49
|
-
const value =
|
|
50
|
-
if (value?.elements.some(e => e.type === 'function-definition')) {
|
|
67
|
+
const value = node_value_1.NodeValue.inGraph.setOf(arg.nodeId, graph, ctx, { resolve: config_1.VariableResolve.Alias });
|
|
68
|
+
if (value?.elements.some(e => e.type === 'function-definition') || readsBuiltInFunction(arg.nodeId, graph, ctx)) {
|
|
51
69
|
return true;
|
|
52
70
|
}
|
|
53
71
|
}
|
|
@@ -20,6 +20,7 @@ export interface State {
|
|
|
20
20
|
* @see {@link CallGraph}
|
|
21
21
|
*/
|
|
22
22
|
export declare const CallGraph: {
|
|
23
|
+
readonly name: "CallGraph";
|
|
23
24
|
/**
|
|
24
25
|
* Extracts the sub call graph from the given call graph, starting from the given entry points.
|
|
25
26
|
*/
|
|
@@ -60,5 +61,4 @@ export declare const CallGraph: {
|
|
|
60
61
|
readonly invertGraph: <G extends DataflowGraph>(this: void, graph: G, cleanEnv: REnvironmentInformation) => G;
|
|
61
62
|
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;
|
|
62
63
|
readonly reaches: <G extends DataflowGraph>(this: void, from: NodeId, to: NodeId, graph: G, knownReachability?: DefaultMap<NodeId, Set<NodeId>>) => boolean;
|
|
63
|
-
readonly name: "CallGraph";
|
|
64
64
|
};
|
|
@@ -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
|
*/
|
|
@@ -20,6 +20,7 @@ import { Identifier } from '../environments/identifier';
|
|
|
20
20
|
* - {@link Dataflow.valueIsUsed}/{@link Dataflow.hasComputedArguments} - for what a call does with, and gets as, values,
|
|
21
21
|
*/
|
|
22
22
|
export declare const Dataflow: {
|
|
23
|
+
readonly name: "Dataflow";
|
|
23
24
|
/**
|
|
24
25
|
* Maps to flowR's dataflow edge helper to work with the edges in the dataflow graph
|
|
25
26
|
*/
|
|
@@ -47,6 +48,7 @@ export declare const Dataflow: {
|
|
|
47
48
|
* Maps to flowR's helper object for the call-graph
|
|
48
49
|
*/
|
|
49
50
|
readonly callGraph: {
|
|
51
|
+
readonly name: "CallGraph";
|
|
50
52
|
readonly computeSubCallGraph: (this: void, graph: CallGraph, entryPoints: Set<NodeId>) => CallGraph;
|
|
51
53
|
readonly entryPoints: (this: void, graph: CallGraph) => Set<NodeId>;
|
|
52
54
|
readonly unreachableCalls: (this: void, graph: CallGraph) => NodeId[];
|
|
@@ -70,7 +72,6 @@ export declare const Dataflow: {
|
|
|
70
72
|
readonly invertGraph: <G extends DataflowGraph>(this: void, graph: G, cleanEnv: REnvironmentInformation) => G;
|
|
71
73
|
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
74
|
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
75
|
};
|
|
75
76
|
};
|
|
76
77
|
/**
|
|
@@ -227,7 +228,6 @@ export declare const Dataflow: {
|
|
|
227
228
|
readonly invertGraph: <G extends DataflowGraph>(this: void, graph: G, cleanEnv: REnvironmentInformation) => G;
|
|
228
229
|
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
230
|
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
231
|
/**
|
|
232
232
|
* Maps to flowR's main graph object to store and manipulate the dataflow graph
|
|
233
233
|
* @see {@link DataflowGraph}
|
|
@@ -26,13 +26,13 @@ const r_base_packages_1 = require("../../util/r-base-packages");
|
|
|
26
26
|
* - {@link Dataflow.valueIsUsed}/{@link Dataflow.hasComputedArguments} - for what a call does with, and gets as, values,
|
|
27
27
|
*/
|
|
28
28
|
exports.Dataflow = {
|
|
29
|
-
name: 'Dataflow',
|
|
30
29
|
/**
|
|
31
30
|
* Maps to flowR's main graph object to store and manipulate the dataflow graph
|
|
32
31
|
* @see {@link DataflowGraph}
|
|
33
32
|
*/
|
|
34
33
|
graph: graph_1.DataflowGraph,
|
|
35
34
|
...graph_helper_1.GraphHelper,
|
|
35
|
+
name: 'Dataflow',
|
|
36
36
|
/**
|
|
37
37
|
* Maps to flowR's dataflow edge helper to work with the edges in the dataflow graph
|
|
38
38
|
*/
|
|
@@ -15,6 +15,7 @@ const identifier_1 = require("../environments/identifier");
|
|
|
15
15
|
const diff_2 = require("../environments/diff");
|
|
16
16
|
const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
17
17
|
const info_1 = require("../info");
|
|
18
|
+
const diff_graph_1 = require("../../util/diff-graph");
|
|
18
19
|
/**
|
|
19
20
|
* This is the underlying function to calculate the difference based on a given context.
|
|
20
21
|
* Use {@link Dataflow.diff} to calculate the diff of two graphs.
|
|
@@ -22,39 +23,7 @@ const info_1 = require("../info");
|
|
|
22
23
|
function diffDataflowGraph(ctx) {
|
|
23
24
|
diffRootVertices(ctx);
|
|
24
25
|
diffVertices(ctx);
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
function diffOutgoingEdges(ctx) {
|
|
28
|
-
const lEdges = new Map(ctx.left.edges());
|
|
29
|
-
const rEdges = new Map(ctx.right.edges());
|
|
30
|
-
if (lEdges.size < rEdges.size && !ctx.config.leftIsSubgraph || lEdges.size > rEdges.size && !ctx.config.rightIsSubgraph) {
|
|
31
|
-
ctx.report.addComment(`Detected different number of edges! ${ctx.leftname} has ${lEdges.size} (${JSON.stringify(lEdges, json_1.jsonReplacer)}). ${ctx.rightname} has ${rEdges.size} ${JSON.stringify(rEdges, json_1.jsonReplacer)}`);
|
|
32
|
-
}
|
|
33
|
-
for (const [id, edge] of lEdges) {
|
|
34
|
-
/* This has nothing to do with the subset relation as we verify this in the same graph.
|
|
35
|
-
* Yet we still do the check as a subgraph may not have to have all source vertices for edges.
|
|
36
|
-
*/
|
|
37
|
-
if (!ctx.left.hasVertex(id)) {
|
|
38
|
-
if (!ctx.config.leftIsSubgraph) {
|
|
39
|
-
ctx.report.addComment(`The source ${id} of edges ${JSON.stringify(edge, json_1.jsonReplacer)} is not present in ${ctx.leftname}. This means that the graph contains an edge but not the corresponding vertex.`);
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
diffEdges(ctx, id, edge, rEdges.get(id));
|
|
44
|
-
}
|
|
45
|
-
// just to make it both ways in case the length differs
|
|
46
|
-
for (const [id, edge] of rEdges) {
|
|
47
|
-
if (!ctx.right.hasVertex(id)) {
|
|
48
|
-
if (!ctx.config.rightIsSubgraph) {
|
|
49
|
-
ctx.report.addComment(`The source ${id} of edges ${JSON.stringify(edge, json_1.jsonReplacer)} is not present in ${ctx.rightname}. This means that the graph contains an edge but not the corresponding vertex.`);
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
if (!ctx.config.leftIsSubgraph && !lEdges.has(id)) {
|
|
54
|
-
diffEdges(ctx, id, undefined, edge);
|
|
55
|
-
}
|
|
56
|
-
/* otherwise, we already cover the edge above */
|
|
57
|
-
}
|
|
26
|
+
diff_graph_1.GraphDiff.outgoingEdges(ctx, diffEdges);
|
|
58
27
|
}
|
|
59
28
|
function diffRootVertices(ctx) {
|
|
60
29
|
(0, diff_1.setDifference)(ctx.left.rootIds(), ctx.right.rootIds(), { ...ctx, position: `${ctx.position}Root vertices differ in graphs. ` });
|
|
@@ -319,27 +288,6 @@ function diffEdge(edge, otherEdge, ctx, id, target) {
|
|
|
319
288
|
* Compares two sets of outgoing edges and reports differences.
|
|
320
289
|
*/
|
|
321
290
|
function diffEdges(ctx, id, lEdges, rEdges) {
|
|
322
|
-
|
|
323
|
-
if ((lEdges === undefined && !ctx.config.leftIsSubgraph)
|
|
324
|
-
|| (rEdges === undefined && !ctx.config.rightIsSubgraph)) {
|
|
325
|
-
ctx.report.addComment(`Vertex ${id} has undefined outgoing edges. ${ctx.leftname}: ${JSON.stringify(lEdges, json_1.jsonReplacer)} vs ${ctx.rightname}: ${JSON.stringify(rEdges, json_1.jsonReplacer)}`, { tag: 'vertex', id });
|
|
326
|
-
}
|
|
327
|
-
return;
|
|
328
|
-
}
|
|
329
|
-
if (lEdges.size < rEdges.size && !ctx.config.leftIsSubgraph
|
|
330
|
-
|| lEdges.size > rEdges.size && !ctx.config.rightIsSubgraph) {
|
|
331
|
-
ctx.report.addComment(`Vertex ${id} differs in number of outgoing edges. ${ctx.leftname}: [${[...lEdges.keys()].join(',')}] vs ${ctx.rightname}: [${[...rEdges.keys()].join(',')}] `, { tag: 'vertex', id });
|
|
332
|
-
}
|
|
333
|
-
// order independent compare
|
|
334
|
-
for (const [target, edge] of lEdges) {
|
|
335
|
-
const otherEdge = rEdges.get(target);
|
|
336
|
-
if (otherEdge === undefined) {
|
|
337
|
-
if (!ctx.config.rightIsSubgraph) {
|
|
338
|
-
ctx.report.addComment(`Target of ${id}->${target} in ${ctx.leftname} is not present in ${ctx.rightname}`, { tag: 'edge', from: id, to: target });
|
|
339
|
-
}
|
|
340
|
-
continue;
|
|
341
|
-
}
|
|
342
|
-
diffEdge(edge, otherEdge, ctx, id, target);
|
|
343
|
-
}
|
|
291
|
+
diff_graph_1.GraphDiff.edges(ctx, id, lEdges, rEdges, diffEdge);
|
|
344
292
|
}
|
|
345
293
|
//# sourceMappingURL=diff-dataflow-graph.js.map
|
|
@@ -15,6 +15,7 @@ import { DefaultMap } from '../../util/collections/defaultmap';
|
|
|
15
15
|
* - {@link CallGraph}
|
|
16
16
|
*/
|
|
17
17
|
export declare const GraphHelper: {
|
|
18
|
+
readonly name: "GraphHelper";
|
|
18
19
|
/** Maps to the mermaid-centric visualization helper for dataflow graphs and their views */
|
|
19
20
|
readonly visualize: {
|
|
20
21
|
/**
|
|
@@ -17,6 +17,7 @@ const defaultmap_1 = require("../../util/collections/defaultmap");
|
|
|
17
17
|
* - {@link CallGraph}
|
|
18
18
|
*/
|
|
19
19
|
exports.GraphHelper = {
|
|
20
|
+
name: 'GraphHelper',
|
|
20
21
|
/** Maps to the mermaid-centric visualization helper for dataflow graphs and their views */
|
|
21
22
|
visualize: {
|
|
22
23
|
/**
|
|
@@ -277,6 +277,11 @@ export declare class DataflowGraph<Vertex extends DataflowGraphVertexInfo = Data
|
|
|
277
277
|
*/
|
|
278
278
|
isRoot(id: NodeId): boolean;
|
|
279
279
|
rootIds(): ReadonlySet<NodeId>;
|
|
280
|
+
/**
|
|
281
|
+
* Takes `type` off the edge `fromId -> toId`, dropping the edge itself once it states nothing.
|
|
282
|
+
* An edge with no type is no edge: every removal has to go through here so none is left behind.
|
|
283
|
+
*/
|
|
284
|
+
removeEdgeType(fromId: NodeId, toId: NodeId, type: EdgeType | number): this;
|
|
280
285
|
/**
|
|
281
286
|
* Adds a new vertex to the graph, for ease of use, some arguments are optional and filled automatically.
|
|
282
287
|
* @param vertex - The vertex to add
|
package/dataflow/graph/graph.js
CHANGED
|
@@ -328,6 +328,33 @@ class DataflowGraph {
|
|
|
328
328
|
rootIds() {
|
|
329
329
|
return this.rootVertices;
|
|
330
330
|
}
|
|
331
|
+
/**
|
|
332
|
+
* Takes `type` off the edge `fromId -> toId`, dropping the edge itself once it states nothing.
|
|
333
|
+
* An edge with no type is no edge: every removal has to go through here so none is left behind.
|
|
334
|
+
*/
|
|
335
|
+
removeEdgeType(fromId, toId, type) {
|
|
336
|
+
const from = node_id_1.NodeId.normalize(fromId), to = node_id_1.NodeId.normalize(toId);
|
|
337
|
+
const targets = this.edgeInformation.get(from);
|
|
338
|
+
const edge = targets?.get(to);
|
|
339
|
+
if (edge === undefined || targets === undefined) {
|
|
340
|
+
return this;
|
|
341
|
+
}
|
|
342
|
+
edge.types &= ~type;
|
|
343
|
+
if (edge.types !== 0) {
|
|
344
|
+
/* the reverse index holds this very object, so a narrowed type is already visible through it */
|
|
345
|
+
return this;
|
|
346
|
+
}
|
|
347
|
+
targets.delete(to);
|
|
348
|
+
if (targets.size === 0) {
|
|
349
|
+
this.edgeInformation.delete(from);
|
|
350
|
+
}
|
|
351
|
+
const into = this.incomingIndex?.get(to);
|
|
352
|
+
into?.delete(from);
|
|
353
|
+
if (into?.size === 0) {
|
|
354
|
+
this.incomingIndex?.delete(to);
|
|
355
|
+
}
|
|
356
|
+
return this;
|
|
357
|
+
}
|
|
331
358
|
/**
|
|
332
359
|
* Adds a new vertex to the graph, for ease of use, some arguments are optional and filled automatically.
|
|
333
360
|
* @param vertex - The vertex to add
|
|
@@ -178,16 +178,19 @@ export type DataflowGraphVertexInfo = Required<DataflowGraphVertexArgument>;
|
|
|
178
178
|
export type DataflowGraphVertices<Vertex extends DataflowGraphVertexInfo = DataflowGraphVertexInfo> = Map<NodeId, Vertex>;
|
|
179
179
|
/** Helpers for {@link DataflowGraphVertexValue} vertices. */
|
|
180
180
|
export declare const ValueVertex: {
|
|
181
|
+
name: string;
|
|
181
182
|
/** Whether the given vertex is a value vertex. */
|
|
182
183
|
is(this: void, vertex?: DataflowGraphVertexBase): vertex is DataflowGraphVertexValue;
|
|
183
184
|
};
|
|
184
185
|
/** Helpers for {@link DataflowGraphVertexUse} vertices. */
|
|
185
186
|
export declare const UseVertex: {
|
|
187
|
+
name: string;
|
|
186
188
|
/** Whether the given vertex is a use vertex. */
|
|
187
189
|
is(this: void, vertex?: DataflowGraphVertexBase): vertex is DataflowGraphVertexUse;
|
|
188
190
|
};
|
|
189
191
|
/** Helpers for {@link DataflowGraphVertexFunctionCall} vertices. */
|
|
190
192
|
export declare const FunctionCallVertex: {
|
|
193
|
+
name: string;
|
|
191
194
|
/** Whether the given vertex is a function call vertex. */
|
|
192
195
|
is(this: void, vertex?: DataflowGraphVertexBase): vertex is DataflowGraphVertexFunctionCall;
|
|
193
196
|
/** Whether the given vertex is a function call carrying the given origin. */
|
|
@@ -195,11 +198,13 @@ export declare const FunctionCallVertex: {
|
|
|
195
198
|
};
|
|
196
199
|
/** Helpers for {@link DataflowGraphVertexVariableDefinition} vertices. */
|
|
197
200
|
export declare const VariableDefinitionVertex: {
|
|
201
|
+
name: string;
|
|
198
202
|
/** Whether the given vertex is a variable definition vertex. */
|
|
199
203
|
is(this: void, vertex?: DataflowGraphVertexBase): vertex is DataflowGraphVertexVariableDefinition;
|
|
200
204
|
};
|
|
201
205
|
/** Helpers for {@link DataflowGraphVertexFunctionDefinition} vertices. */
|
|
202
206
|
export declare const FunctionDefinitionVertex: {
|
|
207
|
+
name: string;
|
|
203
208
|
/** Whether the given vertex is a function definition vertex. */
|
|
204
209
|
is(this: void, vertex?: DataflowGraphVertexBase): vertex is DataflowGraphVertexFunctionDefinition;
|
|
205
210
|
};
|