@eagleoutice/flowr 2.10.9 → 2.10.10
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 +103 -33
- package/abstract-interpretation/absint-visitor.js +6 -3
- package/abstract-interpretation/domains/abstract-domain.d.ts +1 -1
- package/abstract-interpretation/domains/bounded-set-domain.d.ts +1 -1
- package/abstract-interpretation/domains/bounded-set-domain.js +1 -1
- package/abstract-interpretation/domains/interval-domain.d.ts +1 -1
- package/abstract-interpretation/domains/interval-domain.js +1 -1
- package/abstract-interpretation/domains/lattice.d.ts +1 -1
- package/abstract-interpretation/domains/partial-product-domain.d.ts +1 -1
- package/abstract-interpretation/domains/partial-product-domain.js +2 -2
- package/abstract-interpretation/domains/set-range-domain.d.ts +1 -1
- package/abstract-interpretation/domains/set-range-domain.js +1 -1
- package/abstract-interpretation/domains/set-upper-bound-domain.d.ts +1 -1
- package/abstract-interpretation/domains/set-upper-bound-domain.js +1 -1
- package/abstract-interpretation/domains/singleton-domain.d.ts +1 -1
- package/abstract-interpretation/domains/singleton-domain.js +1 -1
- package/abstract-interpretation/domains/state-abstract-domain.d.ts +1 -1
- package/abstract-interpretation/domains/state-abstract-domain.js +2 -2
- package/abstract-interpretation/unsupported-functions.d.ts +3 -2
- package/abstract-interpretation/unsupported-functions.js +38 -28
- package/cli/benchmark-app.js +2 -1
- package/cli/common/script.js +3 -2
- package/cli/flowr.js +47 -10
- package/cli/repl/commands/repl-cfg.js +9 -9
- package/cli/repl/commands/repl-commands.js +5 -0
- package/cli/repl/commands/repl-dataflow.js +31 -24
- package/cli/repl/commands/repl-main.d.ts +6 -0
- package/cli/repl/commands/repl-normalize.js +15 -12
- package/cli/repl/commands/repl-parse.js +1 -1
- package/cli/repl/commands/repl-query.js +4 -5
- package/cli/repl/commands/repl-quit.js +2 -1
- package/cli/repl/core.d.ts +11 -0
- package/cli/repl/core.js +101 -3
- package/cli/repl/execute.js +3 -2
- package/cli/repl/parser/slice-query-parser.d.ts +16 -0
- package/cli/repl/parser/slice-query-parser.js +52 -0
- package/cli/repl/server/connection.d.ts +1 -0
- package/cli/repl/server/connection.js +25 -0
- package/cli/repl/server/messages/message-analysis.d.ts +10 -0
- package/cli/repl/server/messages/message-analysis.js +6 -2
- package/cli/repl/server/messages/message-slice.d.ts +1 -1
- package/cli/script-core/statistics-core.js +2 -1
- package/cli/script-core/statistics-helper-core.js +2 -1
- package/cli/wiki.d.ts +2 -1
- package/cli/wiki.js +4 -1
- package/config.d.ts +9 -10
- package/config.js +25 -7
- package/control-flow/diff-cfg.d.ts +1 -1
- package/control-flow/diff-cfg.js +1 -1
- package/control-flow/semantic-cfg-guided-visitor.js +1 -0
- package/control-flow/simple-visitor.js +6 -5
- package/control-flow/useless-loop.js +2 -2
- package/core/print/dataflow-printer.d.ts +2 -2
- package/core/print/dataflow-printer.js +2 -2
- package/core/steps/all/static-slicing/00-slice.js +1 -1
- package/core/steps/pipeline/default-pipelines.d.ts +146 -146
- package/dataflow/environments/append.d.ts +2 -1
- package/dataflow/environments/append.js +2 -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.d.ts +2 -0
- package/dataflow/environments/built-in.js +2 -0
- package/dataflow/environments/default-builtin-config.d.ts +122 -66
- package/dataflow/environments/default-builtin-config.js +324 -145
- package/dataflow/environments/environment.d.ts +2 -1
- package/dataflow/environments/environment.js +13 -9
- package/dataflow/environments/identifier.d.ts +55 -2
- package/dataflow/environments/identifier.js +14 -2
- package/dataflow/environments/reference-to-maybe.d.ts +2 -0
- package/dataflow/environments/reference-to-maybe.js +56 -11
- package/dataflow/environments/resolve-by-name.js +13 -7
- package/dataflow/eval/values/general.js +4 -0
- package/dataflow/extractor.js +12 -2
- package/dataflow/graph/df-helper.d.ts +6 -0
- package/dataflow/graph/df-helper.js +33 -0
- package/dataflow/graph/graph.js +1 -1
- package/dataflow/info.d.ts +1 -1
- package/dataflow/internal/linker.d.ts +5 -1
- package/dataflow/internal/linker.js +34 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +53 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.d.ts +13 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.js +58 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +38 -14
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +9 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +1 -1
- package/dataflow/internal/process/functions/call/known-call-handling.js +4 -3
- package/dataflow/internal/process/functions/call/named-call-handling.js +6 -0
- package/dataflow/origin/dfg-get-origin.d.ts +1 -1
- package/dataflow/origin/dfg-get-origin.js +1 -1
- package/dataflow/processor.d.ts +6 -0
- package/documentation/data/faq/faqs.d.ts +2 -1
- package/documentation/data/faq/faqs.js +75 -57
- package/documentation/data/server/doc-data-server-messages.d.ts +2 -1
- package/documentation/data/server/doc-data-server-messages.js +15 -7
- package/documentation/doc-readme.js +15 -15
- package/documentation/doc-util/doc-cfg.d.ts +3 -1
- package/documentation/doc-util/doc-cfg.js +3 -3
- package/documentation/doc-util/doc-dfg.d.ts +3 -1
- package/documentation/doc-util/doc-dfg.js +3 -3
- package/documentation/doc-util/doc-files.d.ts +3 -1
- package/documentation/doc-util/doc-files.js +9 -6
- package/documentation/doc-util/doc-normalized-ast.d.ts +3 -1
- package/documentation/doc-util/doc-normalized-ast.js +2 -2
- package/documentation/doc-util/doc-query.d.ts +2 -1
- package/documentation/doc-util/doc-query.js +2 -2
- package/documentation/doc-util/doc-repl.js +1 -0
- package/documentation/doc-util/doc-types.d.ts +6 -6
- package/documentation/doc-util/doc-types.js +11 -9
- package/documentation/issue-linting-rule.js +1 -2
- package/documentation/wiki-analyzer.js +9 -9
- package/documentation/wiki-cfg.js +40 -41
- package/documentation/wiki-core.js +119 -31
- package/documentation/wiki-create-linting-rules.d.ts +6 -0
- package/documentation/wiki-create-linting-rules.js +95 -0
- package/documentation/wiki-dataflow-graph.js +77 -76
- package/documentation/wiki-engine.js +1 -2
- package/documentation/wiki-faq.d.ts +2 -1
- package/documentation/wiki-faq.js +4 -4
- package/documentation/wiki-interface.js +19 -6
- package/documentation/wiki-linter.d.ts +1 -1
- package/documentation/wiki-linter.js +14 -6
- package/documentation/wiki-linting-and-testing.js +2 -2
- package/documentation/wiki-mk/doc-context.d.ts +3 -3
- package/documentation/wiki-mk/doc-maker.d.ts +2 -0
- package/documentation/wiki-mk/doc-maker.js +7 -1
- package/documentation/wiki-normalized-ast.js +5 -5
- package/documentation/wiki-onboarding.d.ts +2 -1
- package/documentation/wiki-onboarding.js +5 -5
- package/documentation/wiki-overview.js +3 -3
- package/documentation/wiki-query.js +85 -84
- package/documentation/wiki-search.js +4 -5
- package/documentation/wiki-setup.js +6 -7
- package/gas.d.ts +74 -0
- package/gas.js +18 -0
- package/linter/linter-executor.js +2 -8
- package/linter/linter-format.d.ts +4 -11
- package/linter/linter-rules.d.ts +88 -86
- package/linter/linter-rules.js +7 -1
- package/linter/rules/absolute-path.d.ts +2 -7
- package/linter/rules/absolute-path.js +6 -4
- package/linter/rules/dataframe-access-validation.d.ts +1 -6
- package/linter/rules/dataframe-access-validation.js +8 -6
- package/linter/rules/dead-code.d.ts +2 -11
- package/linter/rules/dead-code.js +16 -11
- package/linter/rules/deprecated-functions.d.ts +3 -3
- package/linter/rules/file-path-validity.d.ts +1 -6
- package/linter/rules/file-path-validity.js +5 -5
- package/linter/rules/function-finder-util.d.ts +7 -11
- package/linter/rules/function-finder-util.js +9 -6
- package/linter/rules/naming-convention.d.ts +2 -7
- package/linter/rules/naming-convention.js +3 -2
- package/linter/rules/network-functions.d.ts +2 -7
- package/linter/rules/network-functions.js +14 -12
- package/linter/rules/no-leaked-credentials.d.ts +36 -0
- package/linter/rules/no-leaked-credentials.js +75 -0
- package/linter/rules/problematic-inputs.d.ts +1 -8
- package/linter/rules/problematic-inputs.js +5 -4
- package/linter/rules/roxygen-arguments.d.ts +2 -7
- package/linter/rules/roxygen-arguments.js +13 -20
- package/linter/rules/seeded-randomness.d.ts +2 -7
- package/linter/rules/seeded-randomness.js +7 -4
- package/linter/rules/software-has-license.d.ts +31 -0
- package/linter/rules/software-has-license.js +46 -0
- package/linter/rules/software-has-tests.d.ts +38 -0
- package/linter/rules/software-has-tests.js +48 -0
- package/linter/rules/stop-with-call-arg.d.ts +2 -7
- package/linter/rules/stop-with-call-arg.js +3 -2
- package/linter/rules/unused-definition.d.ts +3 -8
- package/linter/rules/unused-definition.js +7 -5
- package/linter/rules/useless-loop.d.ts +2 -7
- package/linter/rules/useless-loop.js +5 -2
- package/package.json +3 -2
- package/project/context/flowr-analyzer-context.d.ts +13 -14
- package/project/context/flowr-analyzer-context.js +4 -0
- package/project/context/flowr-analyzer-files-context.d.ts +12 -0
- package/project/context/flowr-analyzer-files-context.js +12 -2
- package/project/context/flowr-analyzer-gas-context.d.ts +28 -0
- package/project/context/flowr-analyzer-gas-context.js +101 -0
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +13 -7
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +56 -11
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.js +2 -2
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.d.ts +2 -1
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.js +5 -5
- package/project/plugins/flowr-analyzer-plugin.d.ts +15 -8
- package/project/plugins/flowr-analyzer-plugin.js +14 -7
- package/project/plugins/gas-plugins/flowr-analyzer-gas-plugin.d.ts +19 -0
- package/project/plugins/gas-plugins/flowr-analyzer-gas-plugin.js +35 -0
- package/project/plugins/plugin-registry.d.ts +2 -1
- package/project/plugins/plugin-registry.js +3 -1
- package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.d.ts +22 -0
- package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.js +47 -0
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +1 -1
- package/queries/catalog/call-context-query/call-context-query-executor.js +54 -8
- package/queries/catalog/call-context-query/call-context-query-format.d.ts +2 -2
- package/queries/catalog/dependencies-query/function-info/test-functions.d.ts +2 -0
- package/queries/catalog/dependencies-query/function-info/test-functions.js +18 -177
- package/queries/catalog/df-shape-query/df-shape-query-format.js +1 -1
- package/queries/catalog/dice-query/dice-query-executor.d.ts +8 -0
- package/queries/catalog/dice-query/dice-query-executor.js +52 -0
- package/queries/catalog/dice-query/dice-query-format.d.ts +53 -0
- package/queries/catalog/dice-query/dice-query-format.js +102 -0
- package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -2
- package/queries/catalog/input-sources-query/input-sources-query-format.d.ts +2 -0
- package/queries/catalog/input-sources-query/input-sources-query-format.js +1 -0
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +2 -0
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +1 -0
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +2 -0
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +1 -0
- package/queries/catalog/linter-query/linter-query-executor.js +7 -0
- package/queries/catalog/location-map-query/location-map-query-format.d.ts +2 -0
- package/queries/catalog/location-map-query/location-map-query-format.js +1 -0
- package/queries/catalog/origin-query/origin-query-format.d.ts +2 -0
- package/queries/catalog/origin-query/origin-query-format.js +1 -0
- package/queries/catalog/provenance-query/provenance-query-format.d.ts +2 -0
- package/queries/catalog/provenance-query/provenance-query-format.js +1 -0
- package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +2 -0
- package/queries/catalog/resolve-value-query/resolve-value-query-format.js +1 -0
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +1 -1
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +2 -0
- package/queries/catalog/static-slice-query/static-slice-query-format.js +1 -0
- package/queries/query.d.ts +18 -1
- package/queries/query.js +3 -1
- package/r-bridge/data/data.d.ts +5 -0
- package/r-bridge/data/data.js +6 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +0 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-string.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-string.js +1 -1
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +55 -44
- package/r-bridge/parser.js +2 -9
- package/r-bridge/shell.d.ts +8 -1
- package/r-bridge/shell.js +26 -7
- package/search/flowr-search-builder.d.ts +2 -2
- package/search/flowr-search-builder.js +1 -1
- package/search/flowr-search-filters.d.ts +30 -9
- package/search/flowr-search-filters.js +26 -21
- package/search/search-executor/search-enrichers.d.ts +600 -0
- package/search/search-executor/search-enrichers.js +23 -2
- package/slicing/static/static-slicer.d.ts +39 -11
- package/slicing/static/static-slicer.js +44 -14
- package/util/collections/queue.d.ts +16 -0
- package/util/collections/queue.js +38 -0
- package/util/log.d.ts +1 -1
- package/util/log.js +1 -1
- package/util/mermaid/dfg.d.ts +2 -2
- package/util/mermaid/dfg.js +2 -2
- package/util/objects.d.ts +9 -0
- package/util/objects.js +54 -0
- package/util/proc.d.ts +6 -0
- package/util/proc.js +20 -0
- package/util/version.js +1 -1
|
@@ -5,22 +5,50 @@ import type { NormalizedAst } from '../../r-bridge/lang-4.x/ast/model/processing
|
|
|
5
5
|
import { type REnvironmentInformation } from '../../dataflow/environments/environment';
|
|
6
6
|
import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
7
7
|
import type { DataflowInformation } from '../../dataflow/info';
|
|
8
|
+
import type { DataflowGraph } from '../../dataflow/graph/graph';
|
|
8
9
|
import type { ReadOnlyFlowrAnalyzerContext } from '../../project/context/flowr-analyzer-context';
|
|
9
10
|
import { SliceDirection } from '../../util/slice-direction';
|
|
10
11
|
export declare const slicerLogger: import("tslog").Logger<import("tslog").ILogObj>;
|
|
12
|
+
/** Options for {@link staticSlice}. */
|
|
13
|
+
export interface StaticSliceOptions {
|
|
14
|
+
/** The analyzer context (environments, configuration). */
|
|
15
|
+
readonly ctx: ReadOnlyFlowrAnalyzerContext;
|
|
16
|
+
/** Dataflow information including the graph to traverse. */
|
|
17
|
+
readonly info: DataflowInformation;
|
|
18
|
+
/** Normalized AST, used for id resolution and nesting info. */
|
|
19
|
+
readonly ast: NormalizedAst;
|
|
20
|
+
/** Seed node ids to start the BFS from. At least one is required. */
|
|
21
|
+
readonly ids: readonly NodeId[];
|
|
22
|
+
/** Whether to slice forward or backward. Defaults to {@link SliceDirection.Backward}. */
|
|
23
|
+
readonly direction?: SliceDirection;
|
|
24
|
+
/**
|
|
25
|
+
* Maximum BFS visits before the algorithm switches to over-approximation (includes everything).
|
|
26
|
+
* Defaults to 75.
|
|
27
|
+
*/
|
|
28
|
+
readonly threshold?: number;
|
|
29
|
+
/** Memoization cache that can be shared across multiple slices on the same graph. */
|
|
30
|
+
readonly cache?: Map<Fingerprint, Set<NodeId>>;
|
|
31
|
+
/**
|
|
32
|
+
* Pre-built graph to use for BFS traversal instead of (possibly inverting) `info.graph`.
|
|
33
|
+
* `info.graph` is still consulted for function-call resolution, so it must remain the non-inverted original.
|
|
34
|
+
* Used by {@link staticDice} to pass a reduced-and-inverted graph in a single allocation.
|
|
35
|
+
*/
|
|
36
|
+
readonly sliceGraph?: DataflowGraph;
|
|
37
|
+
}
|
|
11
38
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* The returned ids can be used to {@link reconstructToCode|reconstruct the slice to R code}.
|
|
15
|
-
* @param ctx - The analyzer context used for slicing.
|
|
16
|
-
* @param info - The dataflow information used for slicing.
|
|
17
|
-
* @param idMap - The mapping from node ids to their information in the AST.
|
|
18
|
-
* @param ids - The seed ids to slice with. Must be at least one.
|
|
19
|
-
* @param direction - The direction to slice in.
|
|
20
|
-
* @param threshold - The maximum number of nodes to visit in the graph. If the threshold is reached, the slice will side with inclusion and drop its minimal guarantee. The limit ensures that the algorithm halts.
|
|
21
|
-
* @param cache - A cache to store the results of the slice. If provided, the slice may use this cache to speed up the slicing process.
|
|
39
|
+
* Computes the node ids to include in a static slice, starting from the given seed ids.
|
|
40
|
+
* The returned ids can be used with {@link reconstructToCode} to reproduce executable R code.
|
|
22
41
|
*/
|
|
23
|
-
export declare function staticSlice(
|
|
42
|
+
export declare function staticSlice(options: StaticSliceOptions): Readonly<SliceResult>;
|
|
43
|
+
/**
|
|
44
|
+
* Computes a program dice: only those nodes reachable forward from `startIds` that are also in the backward slice of `endIds`.
|
|
45
|
+
* This effectively selects all paths from the given start nodes that lead to the given end nodes.
|
|
46
|
+
*
|
|
47
|
+
* For performance, the backward slice is computed first (typically the smaller set), then the graph is
|
|
48
|
+
* reduced to that set and its edges are inverted in a single pass via {@link Dataflow.reduceAndInvertGraph}.
|
|
49
|
+
* The forward traversal then runs only within that subgraph, avoiding nodes that cannot contribute to the dice.
|
|
50
|
+
*/
|
|
51
|
+
export declare function staticDice(ctx: ReadOnlyFlowrAnalyzerContext, info: DataflowInformation, ast: NormalizedAst, startIds: readonly NodeId[], endIds: readonly NodeId[], threshold?: number): Readonly<SliceResult>;
|
|
24
52
|
/**
|
|
25
53
|
* Updates the potential addition for the given target node in the visiting queue.
|
|
26
54
|
* This describes vertices that might be added *if* another path reaches them.
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.slicerLogger = void 0;
|
|
4
4
|
exports.staticSlice = staticSlice;
|
|
5
|
+
exports.staticDice = staticDice;
|
|
5
6
|
exports.updatePotentialAddition = updatePotentialAddition;
|
|
6
7
|
const assert_1 = require("../../util/assert");
|
|
7
8
|
const log_1 = require("../../util/log");
|
|
@@ -14,22 +15,24 @@ const slice_direction_1 = require("../../util/slice-direction");
|
|
|
14
15
|
const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
|
|
15
16
|
exports.slicerLogger = log_1.log.getSubLogger({ name: 'slicer' });
|
|
16
17
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* The returned ids can be used to {@link reconstructToCode|reconstruct the slice to R code}.
|
|
20
|
-
* @param ctx - The analyzer context used for slicing.
|
|
21
|
-
* @param info - The dataflow information used for slicing.
|
|
22
|
-
* @param idMap - The mapping from node ids to their information in the AST.
|
|
23
|
-
* @param ids - The seed ids to slice with. Must be at least one.
|
|
24
|
-
* @param direction - The direction to slice in.
|
|
25
|
-
* @param threshold - The maximum number of nodes to visit in the graph. If the threshold is reached, the slice will side with inclusion and drop its minimal guarantee. The limit ensures that the algorithm halts.
|
|
26
|
-
* @param cache - A cache to store the results of the slice. If provided, the slice may use this cache to speed up the slicing process.
|
|
18
|
+
* Computes the node ids to include in a static slice, starting from the given seed ids.
|
|
19
|
+
* The returned ids can be used with {@link reconstructToCode} to reproduce executable R code.
|
|
27
20
|
*/
|
|
28
|
-
function staticSlice(
|
|
21
|
+
function staticSlice(options) {
|
|
22
|
+
const { ctx, info, ids, cache, sliceGraph } = options;
|
|
23
|
+
const { idMap } = options.ast;
|
|
24
|
+
const direction = options.direction ?? slice_direction_1.SliceDirection.Backward;
|
|
25
|
+
const threshold = options.threshold ?? 75;
|
|
29
26
|
(0, assert_1.guard)(ids.length > 0, 'must have at least one seed id to calculate slice');
|
|
30
|
-
let
|
|
31
|
-
if (
|
|
32
|
-
graph =
|
|
27
|
+
let graph;
|
|
28
|
+
if (sliceGraph !== undefined) {
|
|
29
|
+
graph = sliceGraph;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
graph = info.graph;
|
|
33
|
+
if (direction === slice_direction_1.SliceDirection.Forward) {
|
|
34
|
+
graph = df_helper_1.Dataflow.invertGraph(graph, ctx.env.makeCleanEnv());
|
|
35
|
+
}
|
|
33
36
|
}
|
|
34
37
|
const queue = new visiting_queue_1.VisitingQueue(threshold, cache);
|
|
35
38
|
let minNesting = Number.MAX_SAFE_INTEGER;
|
|
@@ -107,6 +110,33 @@ function staticSlice(ctx, info, { idMap }, ids, direction, threshold = 75, cache
|
|
|
107
110
|
return { ...queue.status(), slicedFor: ids };
|
|
108
111
|
}
|
|
109
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* Computes a program dice: only those nodes reachable forward from `startIds` that are also in the backward slice of `endIds`.
|
|
115
|
+
* This effectively selects all paths from the given start nodes that lead to the given end nodes.
|
|
116
|
+
*
|
|
117
|
+
* For performance, the backward slice is computed first (typically the smaller set), then the graph is
|
|
118
|
+
* reduced to that set and its edges are inverted in a single pass via {@link Dataflow.reduceAndInvertGraph}.
|
|
119
|
+
* The forward traversal then runs only within that subgraph, avoiding nodes that cannot contribute to the dice.
|
|
120
|
+
*/
|
|
121
|
+
function staticDice(ctx, info, ast, startIds, endIds, threshold = 75) {
|
|
122
|
+
(0, assert_1.guard)(startIds.length > 0 && endIds.length > 0, 'must have at least one start and one end id for dicing');
|
|
123
|
+
const backward = staticSlice({ ctx, info, ast, ids: endIds, direction: slice_direction_1.SliceDirection.Backward, threshold });
|
|
124
|
+
// reduce to backward result and invert edges in one pass; original info kept for sliceForCall
|
|
125
|
+
const invertedReduced = df_helper_1.Dataflow.reduceAndInvertGraph(info.graph, backward.result, ctx.env.makeCleanEnv());
|
|
126
|
+
const forward = staticSlice({ ctx, info, ast, ids: startIds, direction: slice_direction_1.SliceDirection.Backward, threshold, sliceGraph: invertedReduced });
|
|
127
|
+
// explicit intersection handles seed nodes that landed outside the reduced graph
|
|
128
|
+
const result = new Set();
|
|
129
|
+
for (const id of forward.result) {
|
|
130
|
+
if (backward.result.has(id)) {
|
|
131
|
+
result.add(id);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return {
|
|
135
|
+
timesHitThreshold: forward.timesHitThreshold + backward.timesHitThreshold,
|
|
136
|
+
result,
|
|
137
|
+
slicedFor: [...startIds, ...endIds],
|
|
138
|
+
};
|
|
139
|
+
}
|
|
110
140
|
function extendSlices(results, ast) {
|
|
111
141
|
const res = new Set();
|
|
112
142
|
for (const id of results) {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A FIFO queue over a growable array with amortized O(1) dequeue.
|
|
3
|
+
* Entries are consumed via an index (instead of costly `Array#shift` calls),
|
|
4
|
+
* and the consumed prefix is dropped once it dominates the array,
|
|
5
|
+
* bounding the memory overhead to twice the live queue size.
|
|
6
|
+
*/
|
|
7
|
+
export declare class ArrayQueue<T> {
|
|
8
|
+
private elements;
|
|
9
|
+
private idx;
|
|
10
|
+
constructor(initial?: readonly T[]);
|
|
11
|
+
enqueue(item: T): void;
|
|
12
|
+
/** Returns the oldest element, or `undefined` if the queue {@link isEmpty}. */
|
|
13
|
+
dequeue(): T | undefined;
|
|
14
|
+
get size(): number;
|
|
15
|
+
isEmpty(): boolean;
|
|
16
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ArrayQueue = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* A FIFO queue over a growable array with amortized O(1) dequeue.
|
|
6
|
+
* Entries are consumed via an index (instead of costly `Array#shift` calls),
|
|
7
|
+
* and the consumed prefix is dropped once it dominates the array,
|
|
8
|
+
* bounding the memory overhead to twice the live queue size.
|
|
9
|
+
*/
|
|
10
|
+
class ArrayQueue {
|
|
11
|
+
elements;
|
|
12
|
+
idx = 0;
|
|
13
|
+
constructor(initial) {
|
|
14
|
+
this.elements = initial ? initial.slice() : [];
|
|
15
|
+
}
|
|
16
|
+
enqueue(item) {
|
|
17
|
+
this.elements.push(item);
|
|
18
|
+
}
|
|
19
|
+
/** Returns the oldest element, or `undefined` if the queue {@link isEmpty}. */
|
|
20
|
+
dequeue() {
|
|
21
|
+
if (this.idx >= this.elements.length) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
if (this.idx > 1024 && this.idx * 2 > this.elements.length) {
|
|
25
|
+
this.elements = this.elements.slice(this.idx);
|
|
26
|
+
this.idx = 0;
|
|
27
|
+
}
|
|
28
|
+
return this.elements[this.idx++];
|
|
29
|
+
}
|
|
30
|
+
get size() {
|
|
31
|
+
return this.elements.length - this.idx;
|
|
32
|
+
}
|
|
33
|
+
isEmpty() {
|
|
34
|
+
return this.idx >= this.elements.length;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.ArrayQueue = ArrayQueue;
|
|
38
|
+
//# sourceMappingURL=queue.js.map
|
package/util/log.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ILogObj, type ISettingsParam, Logger } from 'tslog';
|
|
2
2
|
import { type Options } from 'rotating-file-stream';
|
|
3
|
-
export declare const expensiveTrace: (log: Logger<ILogObj
|
|
3
|
+
export declare const expensiveTrace: (log: Logger<ILogObj> | undefined, supplier: () => string) => void;
|
|
4
4
|
export declare class FlowrLogger extends Logger<ILogObj> {
|
|
5
5
|
/** by keeping track of all children we can propagate updates of the settings (e.g., in tests) */
|
|
6
6
|
private readonly childLoggers;
|
package/util/log.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.log = exports.FlowrLogger = exports.expensiveTrace = void 0;
|
|
|
4
4
|
const tslog_1 = require("tslog");
|
|
5
5
|
const rotating_file_stream_1 = require("rotating-file-stream");
|
|
6
6
|
const expensiveTrace = (log, supplier) => {
|
|
7
|
-
if (log.settings.minLevel <= 1 /* LogLevel.Trace */) {
|
|
7
|
+
if (log !== undefined && log.settings.minLevel <= 1 /* LogLevel.Trace */) {
|
|
8
8
|
log.trace(supplier());
|
|
9
9
|
}
|
|
10
10
|
};
|
package/util/mermaid/dfg.d.ts
CHANGED
|
@@ -68,12 +68,12 @@ export declare const DataflowMermaid: {
|
|
|
68
68
|
mermaid: MermaidGraph;
|
|
69
69
|
};
|
|
70
70
|
/**
|
|
71
|
-
* This is a simplified version of {@link DataflowMermaid.
|
|
71
|
+
* This is a simplified version of {@link DataflowMermaid.convert}
|
|
72
72
|
*/
|
|
73
73
|
readonly raw: (this: void, graph: DataflowGraph | DataflowInformation, includeEnvironments?: boolean, mark?: ReadonlySet<NodeId>, simplified?: boolean) => string;
|
|
74
74
|
/**
|
|
75
75
|
* Converts a dataflow graph to a mermaid url that visualizes the graph.
|
|
76
|
-
* This is basically a combination of {@link DataflowMermaid.
|
|
76
|
+
* This is basically a combination of {@link DataflowMermaid.raw} and {@link Mermaid.codeToUrl}.
|
|
77
77
|
* @param graph - the dataflow graph to render
|
|
78
78
|
* @param includeEnvironments - whether to include the environment content in the output
|
|
79
79
|
* @param mark - which vertices to highlight in the visualization
|
package/util/mermaid/dfg.js
CHANGED
|
@@ -243,7 +243,7 @@ exports.DataflowMermaid = {
|
|
|
243
243
|
return { string: `${mermaid.nodeLines.join('\n')}\n${mermaid.edgeLines.join('\n')}`, mermaid };
|
|
244
244
|
},
|
|
245
245
|
/**
|
|
246
|
-
* This is a simplified version of {@link DataflowMermaid.
|
|
246
|
+
* This is a simplified version of {@link DataflowMermaid.convert}
|
|
247
247
|
*/
|
|
248
248
|
raw(graph, includeEnvironments, mark, simplified = false) {
|
|
249
249
|
graph = info_2.DataflowInformation.is(graph) ? graph.graph : graph;
|
|
@@ -251,7 +251,7 @@ exports.DataflowMermaid = {
|
|
|
251
251
|
},
|
|
252
252
|
/**
|
|
253
253
|
* Converts a dataflow graph to a mermaid url that visualizes the graph.
|
|
254
|
-
* This is basically a combination of {@link DataflowMermaid.
|
|
254
|
+
* This is basically a combination of {@link DataflowMermaid.raw} and {@link Mermaid.codeToUrl}.
|
|
255
255
|
* @param graph - the dataflow graph to render
|
|
256
256
|
* @param includeEnvironments - whether to include the environment content in the output
|
|
257
257
|
* @param mark - which vertices to highlight in the visualization
|
package/util/objects.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DeepPartial, DeepReadonly, DeepRequired } from 'ts-essentials';
|
|
2
|
+
import type { ILogObj, Logger } from 'tslog';
|
|
2
3
|
/**
|
|
3
4
|
* checks if `item` is an object (it may be an array, ...)
|
|
4
5
|
*/
|
|
@@ -44,4 +45,12 @@ export type AutocompletablePaths<T, Prefix extends string = ''> = T extends Prim
|
|
|
44
45
|
* This is a version of a deep clone that preserves unclonable values (like functions, symbols, ...) by keeping the same reference to them.
|
|
45
46
|
*/
|
|
46
47
|
export declare function deepClonePreserveUnclonable<T>(obj: T): T;
|
|
48
|
+
/**
|
|
49
|
+
* Compares the two passed objects deeply using the loose comparison system designed for the {@link FlowrFilter.MatchesEnrichment}. For this system in use, see {@link FlowrFilter.MatchesEnrichment} in use.
|
|
50
|
+
* @param obj - The real object which we want to test against.
|
|
51
|
+
* @param expected - The object to test the real value {@link obj} against, which should be an object in the shape of {@link obj} with each value to test for replaced by a {@link RegExp} or value to match against. The test will pass if the partial structure matches and the value at each {@link RegExp}, string or primitive location matches the corresponding regular expression. For array entries, {@link arrayMatch} determines whether every element in the array has to match the given expected value, or only some.
|
|
52
|
+
* @param arrayMatch - For array entries, the expected value in {@link test} is compared against each array entry in the real value. This property determines whether every element in the array has to match, or only some. If unset, this defaults to `some`.
|
|
53
|
+
* @param logger - The logger to use for trace debugging.
|
|
54
|
+
*/
|
|
55
|
+
export declare function looselyCompareObjects(obj: Record<string, unknown>, expected: Record<string, unknown>, arrayMatch?: 'some' | 'every', logger?: Logger<ILogObj>): boolean;
|
|
47
56
|
export {};
|
package/util/objects.js
CHANGED
|
@@ -5,7 +5,9 @@ exports.deepMergeObject = deepMergeObject;
|
|
|
5
5
|
exports.deepMergeObjectInPlace = deepMergeObjectInPlace;
|
|
6
6
|
exports.compactRecord = compactRecord;
|
|
7
7
|
exports.deepClonePreserveUnclonable = deepClonePreserveUnclonable;
|
|
8
|
+
exports.looselyCompareObjects = looselyCompareObjects;
|
|
8
9
|
const json_1 = require("./json");
|
|
10
|
+
const log_1 = require("./log");
|
|
9
11
|
/**
|
|
10
12
|
* checks if `item` is an object (it may be an array, ...)
|
|
11
13
|
*/
|
|
@@ -130,4 +132,56 @@ function deepClonePreserveUnclonable(obj) {
|
|
|
130
132
|
return result;
|
|
131
133
|
}
|
|
132
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Compares the two passed objects deeply using the loose comparison system designed for the {@link FlowrFilter.MatchesEnrichment}. For this system in use, see {@link FlowrFilter.MatchesEnrichment} in use.
|
|
137
|
+
* @param obj - The real object which we want to test against.
|
|
138
|
+
* @param expected - The object to test the real value {@link obj} against, which should be an object in the shape of {@link obj} with each value to test for replaced by a {@link RegExp} or value to match against. The test will pass if the partial structure matches and the value at each {@link RegExp}, string or primitive location matches the corresponding regular expression. For array entries, {@link arrayMatch} determines whether every element in the array has to match the given expected value, or only some.
|
|
139
|
+
* @param arrayMatch - For array entries, the expected value in {@link test} is compared against each array entry in the real value. This property determines whether every element in the array has to match, or only some. If unset, this defaults to `some`.
|
|
140
|
+
* @param logger - The logger to use for trace debugging.
|
|
141
|
+
*/
|
|
142
|
+
function looselyCompareObjects(obj, expected, arrayMatch, logger) {
|
|
143
|
+
(0, log_1.expensiveTrace)(logger, () => `Comparing ${JSON.stringify(obj)} against ${JSON.stringify(expected)}`);
|
|
144
|
+
for (const [expectedKey, expectedValue] of Object.entries(expected)) {
|
|
145
|
+
const realValue = obj[expectedKey];
|
|
146
|
+
if (!realValue) {
|
|
147
|
+
(0, log_1.expensiveTrace)(logger, () => `Real value ${JSON.stringify(realValue)} does not exist for expected key ${expectedKey}`);
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
if (Array.isArray(realValue)) {
|
|
151
|
+
const match = typeof expectedValue === 'object' ? expectedValue instanceof RegExp ?
|
|
152
|
+
// if we expect a regular expression but an array is supplied, test each value
|
|
153
|
+
(value) => expectedValue.test(typeof value === 'string' ? value : String(value)) :
|
|
154
|
+
// if we expect an object that is not a regular expression, match against our expected structure
|
|
155
|
+
(value) => looselyCompareObjects(value, expectedValue, arrayMatch, logger) :
|
|
156
|
+
// in any other case (primitives!), match against the exact value
|
|
157
|
+
(value) => expectedValue === value;
|
|
158
|
+
if (!(arrayMatch === 'every' ? realValue.every(match) : realValue.some(match))) {
|
|
159
|
+
(0, log_1.expensiveTrace)(logger, () => `Array ${JSON.stringify(realValue)} does not match expected value ${JSON.stringify(expectedValue)} (array match ${arrayMatch})`);
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
else if (typeof realValue === 'object') {
|
|
164
|
+
// for objects, we recursively match
|
|
165
|
+
if (!looselyCompareObjects(realValue, expectedValue, arrayMatch, logger)) {
|
|
166
|
+
(0, log_1.expensiveTrace)(logger, () => `Object ${JSON.stringify(realValue)} does not match expected object ${JSON.stringify(expectedValue)}`);
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
// for anything else, we match with our regular expression or string
|
|
171
|
+
if (expectedValue instanceof RegExp) {
|
|
172
|
+
if (!expectedValue.test(typeof realValue === 'string' ? realValue : String(realValue))) {
|
|
173
|
+
(0, log_1.expensiveTrace)(logger, () => `Value ${JSON.stringify(realValue)} does not match expected regular expression ${expectedValue}`);
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
else if (typeof expectedValue !== 'object') {
|
|
178
|
+
if (expectedValue !== realValue) {
|
|
179
|
+
(0, log_1.expensiveTrace)(logger, () => `Value ${JSON.stringify(realValue)} does not match expected string ${JSON.stringify(expectedValue)}`);
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
(0, log_1.expensiveTrace)(logger, () => `Object ${JSON.stringify(obj)} matches ${JSON.stringify(expected)}`);
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
133
187
|
//# sourceMappingURL=objects.js.map
|
package/util/proc.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exits after draining stdout/stderr. When Node.js writes to a pipe it does so
|
|
3
|
+
* asynchronously; calling process.exit() directly can truncate pending output.
|
|
4
|
+
* Falls back to a forced exit after 1 min in case a drain callback never fires.
|
|
5
|
+
*/
|
|
6
|
+
export declare function exitSafe(code?: number): void;
|
package/util/proc.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.exitSafe = exitSafe;
|
|
4
|
+
/**
|
|
5
|
+
* Exits after draining stdout/stderr. When Node.js writes to a pipe it does so
|
|
6
|
+
* asynchronously; calling process.exit() directly can truncate pending output.
|
|
7
|
+
* Falls back to a forced exit after 1 min in case a drain callback never fires.
|
|
8
|
+
*/
|
|
9
|
+
function exitSafe(code = 0) {
|
|
10
|
+
let pending = 2;
|
|
11
|
+
const done = () => {
|
|
12
|
+
if (--pending === 0) {
|
|
13
|
+
process.exit(code);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
process.stdout.write('', done);
|
|
17
|
+
process.stderr.write('', done);
|
|
18
|
+
setTimeout(() => process.exit(code), 60_000).unref();
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=proc.js.map
|
package/util/version.js
CHANGED
|
@@ -6,7 +6,7 @@ exports.printVersionInformation = printVersionInformation;
|
|
|
6
6
|
const semver_1 = require("semver");
|
|
7
7
|
const assert_1 = require("./assert");
|
|
8
8
|
// this is automatically replaced with the current version by release-it
|
|
9
|
-
const version = '2.10.
|
|
9
|
+
const version = '2.10.10';
|
|
10
10
|
/**
|
|
11
11
|
* Retrieves the current flowR version as a new {@link SemVer} object.
|
|
12
12
|
*/
|