@eagleoutice/flowr 2.17.9 → 2.17.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/cli/repl/core.js +4 -0
- package/config.d.ts +10 -0
- package/config.js +8 -1
- package/control-flow/control-flow-graph.js +11 -1
- package/dataflow/environments/default-builtin-config/guards-primitive-lang.js +1 -1
- package/dataflow/environments/default-builtin-config/guards.js +6 -1
- package/dataflow/environments/default-builtin-config/index.d.ts +1 -1
- package/dataflow/environments/default-builtin-config/network-access.d.ts +1 -1
- package/dataflow/environments/default-builtin-config/network-access.js +2 -0
- package/dataflow/environments/environment.d.ts +2 -0
- package/dataflow/environments/environment.js +5 -0
- package/dataflow/environments/frame-memory.d.ts +9 -0
- package/dataflow/environments/frame-memory.js +37 -0
- package/dataflow/environments/group-generics.d.ts +2 -0
- package/dataflow/environments/group-generics.js +7 -0
- package/dataflow/environments/identifier.d.ts +2 -0
- package/dataflow/environments/identifier.js +16 -0
- package/dataflow/environments/pkg-name.d.ts +1 -0
- package/dataflow/environments/query-fn-props.d.ts +4 -0
- package/dataflow/environments/query-fn-props.js +21 -4
- package/dataflow/environments/resolve-by-name.js +5 -3
- package/dataflow/extractor.js +26 -4
- package/dataflow/fn/guards/call-contracts.js +8 -4
- package/dataflow/fn/guards/function-guards.d.ts +13 -4
- package/dataflow/fn/guards/function-guards.js +147 -52
- package/dataflow/fn/guards/guard-term.d.ts +6 -3
- package/dataflow/fn/guards/guard-term.js +12 -6
- package/dataflow/graph/graph.d.ts +2 -0
- package/dataflow/graph/graph.js +9 -5
- package/dataflow/internal/dispatch-linking.d.ts +6 -0
- package/dataflow/internal/dispatch-linking.js +25 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +32 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +52 -21
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +28 -19
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +75 -0
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +20 -6
- package/dataflow/processor.d.ts +3 -0
- package/documentation/data/faq/faqs.js +4 -0
- package/documentation/wiki-analyzer.js +13 -2
- package/documentation/wiki-interface.js +1 -0
- package/documentation/wiki-linter.js +3 -0
- package/linter/linter-executor.js +4 -1
- package/linter/linter-format.d.ts +5 -5
- package/linter/linter-rules.d.ts +47 -13
- package/linter/linter-rules.js +3 -1
- package/linter/rules/absolute-file-paths.js +1 -1
- package/linter/rules/autoload-files.d.ts +33 -0
- package/linter/rules/autoload-files.js +94 -0
- package/linter/rules/cmd-check/description-metadata.d.ts +2 -2
- package/linter/rules/cmd-check/description-metadata.js +1 -1
- package/linter/rules/cmd-check/documentation-mismatch.d.ts +2 -2
- package/linter/rules/cmd-check/documentation-mismatch.js +1 -1
- package/linter/rules/cmd-check/file-checks.d.ts +6 -11
- package/linter/rules/cmd-check/file-checks.js +8 -3
- package/linter/rules/cmd-check/package-data.d.ts +2 -2
- package/linter/rules/cmd-check/package-data.js +1 -1
- package/linter/rules/cmd-check/package-metafiles.js +1 -1
- package/linter/rules/cmd-check/package-structure.d.ts +2 -2
- package/linter/rules/cmd-check/package-structure.js +1 -1
- package/linter/rules/cmd-check/rd-files.js +1 -1
- package/linter/rules/naming-convention.d.ts +9 -2
- package/linter/rules/process-state-in-session.js +4 -1
- package/linter/rules/software-has-license.d.ts +2 -2
- package/linter/rules/software-has-license.js +1 -2
- package/linter/rules/stop-call.d.ts +8 -3
- package/linter/rules/useless-loop.d.ts +1 -1
- package/package.json +1 -1
- package/project/cache/flowr-analyzer-cache.d.ts +3 -0
- package/project/cache/flowr-analyzer-cache.js +9 -0
- package/project/context/flowr-analyzer-context.d.ts +4 -3
- package/project/context/flowr-analyzer-context.js +18 -6
- package/project/context/flowr-analyzer-dependencies-context.d.ts +9 -0
- package/project/context/flowr-analyzer-dependencies-context.js +35 -6
- package/project/context/flowr-analyzer-environment-context.d.ts +1 -0
- package/project/context/flowr-analyzer-environment-context.js +1 -0
- package/project/context/flowr-analyzer-files-context.d.ts +4 -0
- package/project/context/flowr-analyzer-files-context.js +24 -0
- package/project/context/flowr-analyzer-functions-context.d.ts +1 -0
- package/project/context/flowr-analyzer-functions-context.js +6 -0
- package/project/context/flowr-analyzer-gas-context.d.ts +1 -0
- package/project/context/flowr-analyzer-gas-context.js +1 -0
- package/project/context/flowr-analyzer-incremental-analysis-context.d.ts +24 -0
- package/project/context/flowr-analyzer-incremental-analysis-context.js +54 -0
- package/project/context/flowr-analyzer-loading-order-context.d.ts +1 -0
- package/project/context/flowr-analyzer-loading-order-context.js +14 -0
- package/project/context/flowr-analyzer-meta-context.d.ts +1 -0
- package/project/context/flowr-analyzer-meta-context.js +11 -0
- package/project/context/flowr-file.d.ts +2 -1
- package/project/context/flowr-file.js +5 -2
- package/project/flowr-analyzer.d.ts +22 -3
- package/project/flowr-analyzer.js +36 -0
- package/project/incremental/incremental-dataflow/incremental-dataflow.d.ts +142 -0
- package/project/incremental/incremental-dataflow/incremental-dataflow.js +330 -0
- package/project/plugins/flowr-analyzer-plugin.d.ts +22 -2
- package/project/plugins/flowr-analyzer-plugin.js +16 -1
- package/project/plugins/incremental/incremental-dataflow/flowr-analyzer-incremental-dataflow-heuristic-plugin.d.ts +52 -0
- package/project/plugins/incremental/incremental-dataflow/flowr-analyzer-incremental-dataflow-heuristic-plugin.js +50 -0
- package/project/plugins/incremental/incremental-dataflow/flowr-analyzer-incremental-dataflow-update-type-plugin.d.ts +77 -0
- package/project/plugins/incremental/incremental-dataflow/flowr-analyzer-incremental-dataflow-update-type-plugin.js +151 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +2 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +4 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +1 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +3 -0
- package/project/plugins/plugin-registry.d.ts +3 -1
- package/project/plugins/plugin-registry.js +6 -1
- package/project/sigdb/decode.js +4 -1
- package/project/sigdb/dict.d.ts +7 -4
- package/project/sigdb/dict.js +20 -6
- package/project/sigdb/guarded-source.js +10 -0
- package/project/sigdb/reader.d.ts +8 -2
- package/project/sigdb/reader.js +44 -30
- package/queries/catalog/input-sources-query/simple-input-classifier.js +84 -10
- package/util/flowr-version.d.ts +1 -1
- package/util/flowr-version.js +2 -2
- package/util/objects.d.ts +14 -0
- package/util/objects.js +100 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FlowrConfig } from '../config';
|
|
2
2
|
import type { DeepPartial } from 'ts-essentials';
|
|
3
3
|
import { type KnownParser, type KnownParserInformation } from '../r-bridge/parser';
|
|
4
4
|
import { type Queries, type QueryArgumentsWithType, type QueryResults, type SingleQueryResult, type SupportedQueryTypes } from '../queries/query';
|
|
@@ -13,7 +13,7 @@ import { type GetSearchElements } from '../search/flowr-search-executor';
|
|
|
13
13
|
import type { FlowrAnalyzerContext, ReadOnlyFlowrAnalyzerContext } from './context/flowr-analyzer-context';
|
|
14
14
|
import type { RAnalysisRequest } from './context/flowr-analyzer-files-context';
|
|
15
15
|
import { type RParseRequest, type RParseRequestFromFile, fileProtocol } from '../r-bridge/retriever';
|
|
16
|
-
import type
|
|
16
|
+
import { type FlowrFileProvider } from './context/flowr-file';
|
|
17
17
|
import type { Tree } from 'web-tree-sitter';
|
|
18
18
|
import type { CallGraph } from '../dataflow/graph/call-graph';
|
|
19
19
|
import { type TaintAnalysisBuilder } from '../taint-analysis/builder/taint-analysis';
|
|
@@ -34,7 +34,18 @@ export interface FlowrAnalysisOptions {
|
|
|
34
34
|
*/
|
|
35
35
|
readonly gas?: GasOverrides;
|
|
36
36
|
}
|
|
37
|
-
/**
|
|
37
|
+
/** Options for forking an analyzer */
|
|
38
|
+
export interface ForkOptions {
|
|
39
|
+
/** Shares state until modified */
|
|
40
|
+
readonly lazy?: boolean;
|
|
41
|
+
/** Reuses the dataflow result from the parent analyzer */
|
|
42
|
+
readonly forkDataflow?: boolean;
|
|
43
|
+
/** Decouples inline files instead of using their references */
|
|
44
|
+
readonly decoupleFiles?: boolean;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Extends the {@link ReadonlyFlowrAnalysisProvider} with methods that allow modifying the analyzer state.
|
|
48
|
+
*/
|
|
38
49
|
export interface FlowrAnalysisProvider<Parser extends KnownParser = KnownParser> extends ReadonlyFlowrAnalysisProvider<Parser> {
|
|
39
50
|
/**
|
|
40
51
|
* Returns project context information.
|
|
@@ -55,6 +66,12 @@ export interface FlowrAnalysisProvider<Parser extends KnownParser = KnownParser>
|
|
|
55
66
|
* @see {@link FlowrAnalysisProvider.addRequest|addRequest} - for adding analysis requests to the analyzer.
|
|
56
67
|
*/
|
|
57
68
|
addFile(...f: (string | FlowrFileProvider<string> | RParseRequestFromFile)[]): void;
|
|
69
|
+
/**
|
|
70
|
+
* Tell the analyzer that the file at `path` changed, e.g., as an editor edits it.
|
|
71
|
+
* With `content`, the analyzer analyzes that content instead of what is on disk, without `content` it reads the file again.
|
|
72
|
+
* Only what depends on the file is analyzed again, and with {@link FlowrConfig.incremental.dataflow} the dataflow analysis continues the one before.
|
|
73
|
+
*/
|
|
74
|
+
updateFile(path: string, content?: string): void;
|
|
58
75
|
/** Reset the analyzer state, including the context and the cache. */
|
|
59
76
|
reset(): void;
|
|
60
77
|
/** Receive cache invalidation events from the cache and propagate them to the context and other relevant components. */
|
|
@@ -221,6 +238,7 @@ export declare class FlowrAnalyzer<Parser extends KnownParser = KnownParser> imp
|
|
|
221
238
|
* @param cache - The caching layer to use for storing analysis results.
|
|
222
239
|
*/
|
|
223
240
|
constructor(parser: Parser, ctx: FlowrAnalyzerContext, cache: FlowrAnalyzerCache<Parser>);
|
|
241
|
+
fork(options?: ForkOptions): Promise<FlowrAnalyzer>;
|
|
224
242
|
get flowrConfig(): FlowrConfig;
|
|
225
243
|
context(): FlowrAnalyzerContext;
|
|
226
244
|
parserInformation(): KnownParserInformation;
|
|
@@ -235,6 +253,7 @@ export declare class FlowrAnalyzer<Parser extends KnownParser = KnownParser> imp
|
|
|
235
253
|
normalizeStandalone(data: `${typeof fileProtocol}${string}` | string | RParseRequest): NormalizedAst;
|
|
236
254
|
addRequest(...request: (RAnalysisRequest | readonly RAnalysisRequest[] | `${typeof fileProtocol}${string}` | string)[]): this;
|
|
237
255
|
addFile(...f: (string | FlowrFileProvider | RParseRequestFromFile)[]): this;
|
|
256
|
+
updateFile(path: string, content?: string): this;
|
|
238
257
|
parse(force?: boolean): Promise<NonNullable<AnalyzerCacheType<Parser>['parse']>>;
|
|
239
258
|
peekParse(): NonNullable<AnalyzerCacheType<Parser>['parse']> | undefined;
|
|
240
259
|
normalize(force?: boolean): Promise<NonNullable<AnalyzerCacheType<Parser>['normalize']>>;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FlowrAnalyzer = void 0;
|
|
4
|
+
const config_1 = require("../config");
|
|
4
5
|
const parser_1 = require("../r-bridge/parser");
|
|
5
6
|
const query_1 = require("../queries/query");
|
|
6
7
|
const decorate_1 = require("../r-bridge/lang-4.x/ast/model/processing/decorate");
|
|
7
8
|
const flowr_search_executor_1 = require("../search/flowr-search-executor");
|
|
8
9
|
const retriever_1 = require("../r-bridge/retriever");
|
|
9
10
|
const files_1 = require("../util/files");
|
|
11
|
+
const flowr_file_1 = require("./context/flowr-file");
|
|
10
12
|
const tree_sitter_normalize_1 = require("../r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize");
|
|
11
13
|
const tree_sitter_executor_1 = require("../r-bridge/lang-4.x/tree-sitter/tree-sitter-executor");
|
|
12
14
|
const taint_analysis_1 = require("../taint-analysis/builder/taint-analysis");
|
|
@@ -14,6 +16,7 @@ const taint_analysis_1 = require("../taint-analysis/builder/taint-analysis");
|
|
|
14
16
|
require("../abstract-interpretation/branch-paths-interpreter");
|
|
15
17
|
const vertex_1 = require("../dataflow/graph/vertex");
|
|
16
18
|
const df_helper_1 = require("../dataflow/graph/df-helper");
|
|
19
|
+
const flowr_analyzer_builder_1 = require("./flowr-analyzer-builder");
|
|
17
20
|
/**
|
|
18
21
|
* Central class for conducting analyses with FlowR.
|
|
19
22
|
* Use the {@link FlowrAnalyzerBuilder} to create a new instance.
|
|
@@ -47,6 +50,19 @@ class FlowrAnalyzer {
|
|
|
47
50
|
ctx.setAnalyzer(this);
|
|
48
51
|
this.cache = cache;
|
|
49
52
|
}
|
|
53
|
+
async fork(options) {
|
|
54
|
+
const forkedPlugins = this.ctx.plugins.values().toArray().flat().map(plugin => {
|
|
55
|
+
return typeof plugin.fork === 'function' ? plugin.fork() : plugin;
|
|
56
|
+
});
|
|
57
|
+
const fork = await new flowr_analyzer_builder_1.FlowrAnalyzerBuilder(false)
|
|
58
|
+
.setEngine(this.parser.name)
|
|
59
|
+
.setConfig(config_1.FlowrConfig.clone(this.flowrConfig))
|
|
60
|
+
.registerPlugins(...forkedPlugins)
|
|
61
|
+
.build();
|
|
62
|
+
fork.ctx.fork(this.ctx, options);
|
|
63
|
+
fork.cache.fork(this.cache, options);
|
|
64
|
+
return fork;
|
|
65
|
+
}
|
|
50
66
|
get flowrConfig() {
|
|
51
67
|
return this.ctx.config;
|
|
52
68
|
}
|
|
@@ -110,6 +126,26 @@ class FlowrAnalyzer {
|
|
|
110
126
|
this.ctx.addFiles(f);
|
|
111
127
|
return this;
|
|
112
128
|
}
|
|
129
|
+
updateFile(path, content) {
|
|
130
|
+
const known = this.ctx.files.getFileByPath(path);
|
|
131
|
+
if (content === undefined) {
|
|
132
|
+
known?.invalidate();
|
|
133
|
+
}
|
|
134
|
+
else if (known instanceof flowr_file_1.FlowrInlineTextFile) {
|
|
135
|
+
if (known.content() !== content) {
|
|
136
|
+
known.updateInlineContent(content);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
/* the file stands in for the one known, starting out as what it held, so the change is one from that */
|
|
141
|
+
const before = known === undefined ? undefined : String(known.content());
|
|
142
|
+
const file = new flowr_file_1.FlowrInlineTextFile(known?.path() ?? path, before ?? content);
|
|
143
|
+
this.ctx.addFiles([file]);
|
|
144
|
+
file.content();
|
|
145
|
+
file.updateInlineContent(content);
|
|
146
|
+
}
|
|
147
|
+
return this;
|
|
148
|
+
}
|
|
113
149
|
async parse(force) {
|
|
114
150
|
return this.cache.parse(force);
|
|
115
151
|
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import type { NormalizedAst, ParentInformation, RNodeWithParent } from '../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
2
|
+
import type { FlowrAnalyzerContext } from '../../context/flowr-analyzer-context';
|
|
3
|
+
import type { DataflowInformation } from '../../../dataflow/info';
|
|
4
|
+
import type { DataflowProcessorInformation } from '../../../dataflow/processor';
|
|
5
|
+
import type { ExpressionListCheckpoints, ExpressionListState } from '../../../dataflow/internal/process/functions/call/built-in/built-in-expression-list';
|
|
6
|
+
import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
7
|
+
import type { RProjectFile } from '../../../r-bridge/lang-4.x/ast/model/nodes/r-project';
|
|
8
|
+
import type { IncrementalDataflowPlan } from '../../plugins/incremental/incremental-dataflow/flowr-analyzer-incremental-dataflow-heuristic-plugin';
|
|
9
|
+
import type { FlowrConfig } from '../../../config';
|
|
10
|
+
import { type AnalyzedFile, type IncrementalUpdateResult } from '../../plugins/incremental/incremental-dataflow/flowr-analyzer-incremental-dataflow-update-type-plugin';
|
|
11
|
+
/** The dataflow information before {@link finalizeDataflow} ran over it, together with the processor information that produced it. */
|
|
12
|
+
export interface IncrementalDataflowResult {
|
|
13
|
+
readonly df: DataflowInformation;
|
|
14
|
+
readonly dfData: DataflowProcessorInformation<ParentInformation>;
|
|
15
|
+
}
|
|
16
|
+
export type DataflowProcessorInformationBase<OtherInfo> = Omit<DataflowProcessorInformation<OtherInfo>, 'environment' | 'referenceChain' | 'cds'>;
|
|
17
|
+
/** What the built-in environment, which every analysis of a context shares, notes about the program analyzed. */
|
|
18
|
+
interface ProgramMarks {
|
|
19
|
+
readonly forcing: true | undefined;
|
|
20
|
+
readonly locking: true | undefined;
|
|
21
|
+
readonly methods: true | undefined;
|
|
22
|
+
readonly unknownMethodsAt: NodeId[] | undefined;
|
|
23
|
+
}
|
|
24
|
+
/** What an analysis added to the AST and the context and read, which an analysis continuing it adds again, if it still holds. */
|
|
25
|
+
interface AnalysisAdditions {
|
|
26
|
+
/** the nodes the analysis added to the id map, e.g., those of sourced files, not those later consumers added */
|
|
27
|
+
readonly addedNodes: readonly (readonly [NodeId, RNodeWithParent])[];
|
|
28
|
+
/** the files the analysis added to the AST, i.e., the sourced ones */
|
|
29
|
+
readonly addedFiles: readonly RProjectFile<ParentInformation>[];
|
|
30
|
+
/** the files the analysis read, with the content it read, as a change to one of them invalidates what it computed */
|
|
31
|
+
readonly considered: readonly (readonly [path: string, content: string | undefined])[];
|
|
32
|
+
/**
|
|
33
|
+
* The configuration the analysis ran with, if it stayed the same, as what the analysis learns about the project
|
|
34
|
+
* (e.g., the files a source call reads) may change the {@link ProjectKind} and with it the configuration.
|
|
35
|
+
*/
|
|
36
|
+
readonly config: FlowrConfig | undefined;
|
|
37
|
+
}
|
|
38
|
+
/** What an analysis holds besides the dataflow information up to a checkpoint, and has to be restored to continue from it. */
|
|
39
|
+
interface AnalysisState extends AnalysisAdditions {
|
|
40
|
+
readonly statementOrder: Map<NodeId, [start: number, end: number]> | undefined;
|
|
41
|
+
readonly unreachable: Set<NodeId> | undefined;
|
|
42
|
+
readonly marks: ProgramMarks;
|
|
43
|
+
}
|
|
44
|
+
interface ListCheckpoint extends AnalysisState {
|
|
45
|
+
readonly list: ExpressionListState;
|
|
46
|
+
}
|
|
47
|
+
interface FinalCheckpoint extends AnalysisState {
|
|
48
|
+
readonly df: DataflowInformation;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* What an analysis keeps for the next one: the files it analyzed, and the states it can be continued from.
|
|
52
|
+
* The states are copies, so their size is bounded by {@link FlowrConfig.incremental.dataflow.checkpoints}.
|
|
53
|
+
*/
|
|
54
|
+
export interface DataflowSnapshot {
|
|
55
|
+
readonly files: readonly AnalyzedFile[];
|
|
56
|
+
/** the states of the list of a single analyzed file after some of its top-level statements, ascending by count */
|
|
57
|
+
readonly checkpoints: readonly ListCheckpoint[];
|
|
58
|
+
/** the complete dataflow information of an analysis of multiple files */
|
|
59
|
+
readonly final?: FinalCheckpoint;
|
|
60
|
+
/** what the analysis handed out, after the passes that finalize the graph */
|
|
61
|
+
readonly finalized?: FinalizedDataflow;
|
|
62
|
+
}
|
|
63
|
+
/** A finalized analysis, which an analysis of the same program hands out again as it is, just as a cache hit would. */
|
|
64
|
+
interface FinalizedDataflow extends AnalysisAdditions {
|
|
65
|
+
readonly df: DataflowInformation;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* One dataflow analysis that may reuse what the analysis before it kept, and keeps what the next one may reuse.
|
|
69
|
+
* Created by {@link IncrementalDataflow.begin}.
|
|
70
|
+
*/
|
|
71
|
+
declare class IncrementalDataflowSession implements ExpressionListCheckpoints {
|
|
72
|
+
private readonly ast;
|
|
73
|
+
private readonly ctx;
|
|
74
|
+
private readonly files;
|
|
75
|
+
/** how many nodes the id map held before the analysis, which only adds to it */
|
|
76
|
+
private readonly initialNodes;
|
|
77
|
+
/** how many nodes of the id map the analysis of the statements does not add itself, see {@link resume} */
|
|
78
|
+
private listNodes;
|
|
79
|
+
private readonly initialFiles;
|
|
80
|
+
private readonly initialRead;
|
|
81
|
+
private readonly config;
|
|
82
|
+
private readonly keep;
|
|
83
|
+
/** the number of statements the checkpoints end at, see {@link IncrementalDataflowPlan#after} */
|
|
84
|
+
private readonly after;
|
|
85
|
+
/** whether the analysis resumes from checkpoints, see `incremental.dataflow.activated` */
|
|
86
|
+
private readonly resumes;
|
|
87
|
+
/** whether the analysis hands out the one before again for unchanged files, see `incremental.dataflow.reuse` */
|
|
88
|
+
private readonly reuses;
|
|
89
|
+
private readonly minimum;
|
|
90
|
+
private readonly recorded;
|
|
91
|
+
private readonly update;
|
|
92
|
+
private resumeFrom;
|
|
93
|
+
private reuseFinal;
|
|
94
|
+
/** the first file the reused analysis did not analyze */
|
|
95
|
+
private reuseFrom;
|
|
96
|
+
/** the earlier checkpoints that hold for this analysis too */
|
|
97
|
+
private carried;
|
|
98
|
+
private applied;
|
|
99
|
+
private readonly previous;
|
|
100
|
+
private stored;
|
|
101
|
+
constructor(ast: NormalizedAst, ctx: FlowrAnalyzerContext, previous: DataflowSnapshot | undefined, update: IncrementalUpdateResult | undefined, plan: IncrementalDataflowPlan);
|
|
102
|
+
/** The configuration of this analysis if it stayed the same so far, see {@link AnalysisAdditions#config}. */
|
|
103
|
+
private stableConfig;
|
|
104
|
+
/** Whether the analysis up to the given state would run the same now: with the same configuration, and reading the same files. */
|
|
105
|
+
private holds;
|
|
106
|
+
private unchangedReads;
|
|
107
|
+
private plan;
|
|
108
|
+
/** Reuses the complete dataflow information of the analysis before, if nothing it read changed. */
|
|
109
|
+
reuse<OtherInfo>(base: DataflowProcessorInformationBase<OtherInfo & ParentInformation>): IncrementalDataflowResult | undefined;
|
|
110
|
+
resume<OtherInfo>(fileIndex: number, info: DataflowProcessorInformation<OtherInfo & ParentInformation>): ExpressionListState | undefined;
|
|
111
|
+
wants(count: number, total: number): boolean;
|
|
112
|
+
record<OtherInfo>(fileIndex: number, list: ExpressionListState, info: DataflowProcessorInformation<OtherInfo & ParentInformation>): void;
|
|
113
|
+
/** The state to continue the analysis from: a copy of `changing` and of whatever else the analysis goes on to change, with what it added so far. */
|
|
114
|
+
private stateOf;
|
|
115
|
+
/** A copy that shares what the analysis never changes in place: the AST, the built-in environment, and frozen frames. */
|
|
116
|
+
private copy;
|
|
117
|
+
private restore;
|
|
118
|
+
/** Adds what the analysis before added to the AST and the context again, which a continued analysis does not do itself. */
|
|
119
|
+
private addAgain;
|
|
120
|
+
/** Hands out the finalized analysis before again if the program did not change, which skips the analysis altogether. */
|
|
121
|
+
reuseFinalized(): DataflowInformation | undefined;
|
|
122
|
+
/** Keeps the finalized `df` for {@link reuseFinalized}, and hands it back. */
|
|
123
|
+
finalized(df: DataflowInformation): DataflowInformation;
|
|
124
|
+
/** Keeps what the next analysis may continue from, unless the analysis was cut short. */
|
|
125
|
+
end(result: IncrementalDataflowResult): void;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Helper functions of the incremental dataflow analysis, which continues the analysis before it where the files did not change.
|
|
129
|
+
* The dataflow analysis {@link IncrementalDataflow.begin|begins} a session, which may {@link IncrementalDataflowSession#reuse|reuse} a complete earlier analysis,
|
|
130
|
+
* or hands itself to the processors as their {@link DataflowProcessorInformation#checkpoints|checkpoints} to resume the top-level statements of a file after
|
|
131
|
+
* those that did not change.
|
|
132
|
+
* Either way, it {@link IncrementalDataflowSession#end|ends} before the dataflow is finalized, keeping copies of what the next analysis may continue from.
|
|
133
|
+
*/
|
|
134
|
+
export declare const IncrementalDataflow: {
|
|
135
|
+
readonly name: "IncrementalDataflow";
|
|
136
|
+
/**
|
|
137
|
+
* Begins an incremental dataflow analysis of `ast`, before the analysis adds the files it sources, as the {@link FlowrAnalyzerIncrementalDataflowHeuristicPlugin} plans it
|
|
138
|
+
* for how the files changed; `undefined` if it plans neither to reuse nor to resume, and no analysis before kept its files to compare with.
|
|
139
|
+
*/
|
|
140
|
+
readonly begin: (this: void, ast: NormalizedAst, ctx: FlowrAnalyzerContext) => IncrementalDataflowSession | undefined;
|
|
141
|
+
};
|
|
142
|
+
export type { IncrementalDataflowSession };
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IncrementalDataflow = void 0;
|
|
4
|
+
const built_in_source_1 = require("../../../dataflow/internal/process/functions/call/built-in/built-in-source");
|
|
5
|
+
const environment_1 = require("../../../dataflow/environments/environment");
|
|
6
|
+
const frame_memory_1 = require("../../../dataflow/environments/frame-memory");
|
|
7
|
+
const graph_1 = require("../../../dataflow/graph/graph");
|
|
8
|
+
const objects_1 = require("../../../util/objects");
|
|
9
|
+
const gas_1 = require("../../../gas");
|
|
10
|
+
const flowr_analyzer_incremental_dataflow_update_type_plugin_1 = require("../../plugins/incremental/incremental-dataflow/flowr-analyzer-incremental-dataflow-update-type-plugin");
|
|
11
|
+
/** Whether `o` is the node `idMap` holds for its id, which a copy shares as the AST does not change. */
|
|
12
|
+
function isNodeOf(o, idMap) {
|
|
13
|
+
return 'info' in o && typeof o.info === 'object' && o.info !== null && 'id' in o.info && idMap.get(o.info.id) === o;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The edges are most of what a copy of a graph holds, and nearly all of them only carry their types, so these are copied as they are.
|
|
17
|
+
* A control edge shares its dependency with the vertices behind it, so it goes through the clone; the edges without side effects on calls are derived from the edges, so they start out empty.
|
|
18
|
+
*/
|
|
19
|
+
const GraphCopiers = new Map([
|
|
20
|
+
['edgeInformation', (value, clone) => {
|
|
21
|
+
const copy = new Map();
|
|
22
|
+
for (const [from, targets] of value) {
|
|
23
|
+
const copied = new Map();
|
|
24
|
+
for (const [to, edge] of targets) {
|
|
25
|
+
copied.set(to, edge.cd === undefined ? { types: edge.types } : clone(edge));
|
|
26
|
+
}
|
|
27
|
+
copy.set(from, copied);
|
|
28
|
+
}
|
|
29
|
+
return copy;
|
|
30
|
+
}],
|
|
31
|
+
['beyondSideEffects', () => new Map()]
|
|
32
|
+
]);
|
|
33
|
+
/** what a graph, an environment, and a frame derive from what they hold on demand is left out, so a copy rebuilds it when it needs it */
|
|
34
|
+
const GraphFields = { drop: new Set(['incomingIndex', 'qualifiedNames', 'targetWalks', 'derived']), replace: GraphCopiers };
|
|
35
|
+
const EnvironmentFields = { drop: new Set(['cache', 'tailCache']) };
|
|
36
|
+
const FrameFields = { drop: new Set(['flat', 'flatKeys']) };
|
|
37
|
+
function clonedFieldsOf(owner) {
|
|
38
|
+
return owner instanceof graph_1.DataflowGraph ? GraphFields : owner instanceof environment_1.Environment ? EnvironmentFields : owner instanceof frame_memory_1.Frame ? FrameFields : undefined;
|
|
39
|
+
}
|
|
40
|
+
/** The nodes `idMap` gained since it held `before` of them: it only grows during an analysis, and keeps the nodes in the order they were added. */
|
|
41
|
+
function nodesAddedSince(idMap, before) {
|
|
42
|
+
return idMap.size > before ? [...idMap.entries().drop(before)] : [];
|
|
43
|
+
}
|
|
44
|
+
function cfgOf(info) {
|
|
45
|
+
return info === undefined ? undefined : { entryPoint: info.entryPoint, cfgEntry: info.cfgEntry, cfgExit: info.cfgExit, exitPoints: info.exitPoints, hooks: info.hooks };
|
|
46
|
+
}
|
|
47
|
+
function marksOf(environment) {
|
|
48
|
+
const builtIn = environment_1.REnvironment.findBuiltIn(environment);
|
|
49
|
+
return { forcing: builtIn.forcing, locking: builtIn.locking, methods: builtIn.methods, unknownMethodsAt: builtIn.unknownMethodsAt?.slice() };
|
|
50
|
+
}
|
|
51
|
+
function restoreMarks(environment, marks) {
|
|
52
|
+
const builtIn = environment_1.REnvironment.findBuiltIn(environment);
|
|
53
|
+
builtIn.forcing = marks.forcing;
|
|
54
|
+
builtIn.locking = marks.locking;
|
|
55
|
+
builtIn.methods = marks.methods;
|
|
56
|
+
builtIn.unknownMethodsAt = marks.unknownMethodsAt?.slice();
|
|
57
|
+
}
|
|
58
|
+
function contentOf(ctx, path) {
|
|
59
|
+
try {
|
|
60
|
+
const content = ctx.files.resolveFile(path)?.content();
|
|
61
|
+
return typeof content === 'string' ? content : undefined;
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* One dataflow analysis that may reuse what the analysis before it kept, and keeps what the next one may reuse.
|
|
69
|
+
* Created by {@link IncrementalDataflow.begin}.
|
|
70
|
+
*/
|
|
71
|
+
class IncrementalDataflowSession {
|
|
72
|
+
ast;
|
|
73
|
+
ctx;
|
|
74
|
+
files;
|
|
75
|
+
/** how many nodes the id map held before the analysis, which only adds to it */
|
|
76
|
+
initialNodes;
|
|
77
|
+
/** how many nodes of the id map the analysis of the statements does not add itself, see {@link resume} */
|
|
78
|
+
listNodes;
|
|
79
|
+
initialFiles;
|
|
80
|
+
initialRead;
|
|
81
|
+
config;
|
|
82
|
+
keep;
|
|
83
|
+
/** the number of statements the checkpoints end at, see {@link IncrementalDataflowPlan#after} */
|
|
84
|
+
after;
|
|
85
|
+
/** whether the analysis resumes from checkpoints, see `incremental.dataflow.activated` */
|
|
86
|
+
resumes;
|
|
87
|
+
/** whether the analysis hands out the one before again for unchanged files, see `incremental.dataflow.reuse` */
|
|
88
|
+
reuses;
|
|
89
|
+
minimum;
|
|
90
|
+
recorded = [];
|
|
91
|
+
update;
|
|
92
|
+
resumeFrom;
|
|
93
|
+
reuseFinal;
|
|
94
|
+
/** the first file the reused analysis did not analyze */
|
|
95
|
+
reuseFrom = 0;
|
|
96
|
+
/** the earlier checkpoints that hold for this analysis too */
|
|
97
|
+
carried = [];
|
|
98
|
+
applied = false;
|
|
99
|
+
previous;
|
|
100
|
+
stored;
|
|
101
|
+
constructor(ast, ctx, previous, update, plan) {
|
|
102
|
+
this.ast = ast;
|
|
103
|
+
this.ctx = ctx;
|
|
104
|
+
this.files = ast.ast.files.map(f => ({ filePath: f.filePath, root: f.root }));
|
|
105
|
+
this.initialNodes = ast.idMap.size;
|
|
106
|
+
this.listNodes = this.initialNodes;
|
|
107
|
+
this.initialFiles = ast.ast.files.length;
|
|
108
|
+
this.initialRead = ctx.files.consideredFilesList().length;
|
|
109
|
+
this.config = ctx.config;
|
|
110
|
+
this.keep = plan.checkpoints;
|
|
111
|
+
this.after = plan.after ?? Infinity;
|
|
112
|
+
this.resumes = plan.checkpoints > 0;
|
|
113
|
+
this.reuses = plan.reuse;
|
|
114
|
+
this.minimum = plan.minStatements;
|
|
115
|
+
this.previous = previous;
|
|
116
|
+
this.update = update;
|
|
117
|
+
if (previous !== undefined && update !== undefined) {
|
|
118
|
+
this.plan(previous, update);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/** The configuration of this analysis if it stayed the same so far, see {@link AnalysisAdditions#config}. */
|
|
122
|
+
stableConfig() {
|
|
123
|
+
return this.ctx.config === this.config ? this.config : undefined;
|
|
124
|
+
}
|
|
125
|
+
/** Whether the analysis up to the given state would run the same now: with the same configuration, and reading the same files. */
|
|
126
|
+
holds(state) {
|
|
127
|
+
return state.config === this.config && this.unchangedReads(state.considered);
|
|
128
|
+
}
|
|
129
|
+
unchangedReads(considered) {
|
|
130
|
+
return considered.every(([path, content]) => contentOf(this.ctx, path) === content);
|
|
131
|
+
}
|
|
132
|
+
plan(previous, update) {
|
|
133
|
+
const unchanged = flowr_analyzer_incremental_dataflow_update_type_plugin_1.IncrementalUpdate.unchanged(update) || flowr_analyzer_incremental_dataflow_update_type_plugin_1.IncrementalUpdate.is(update, flowr_analyzer_incremental_dataflow_update_type_plugin_1.IncrementalUpdateType.NewFileAtEnd);
|
|
134
|
+
if (unchanged && previous.final !== undefined && this.holds(previous.final)) {
|
|
135
|
+
this.reuseFinal = previous.final;
|
|
136
|
+
this.reuseFrom = previous.files.length;
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const prefix = unchanged ? previous.files[0]?.root.children.length : update.commonPrefix;
|
|
140
|
+
if (prefix === undefined) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
const usable = previous.checkpoints.filter(c => c.list.count <= prefix && this.holds(c));
|
|
144
|
+
this.resumeFrom = usable.at(-1);
|
|
145
|
+
const total = this.ast.ast.files[0].root.children.length;
|
|
146
|
+
this.carried = usable.filter(c => c !== this.resumeFrom && this.wants(c.list.count, total));
|
|
147
|
+
}
|
|
148
|
+
/** Reuses the complete dataflow information of the analysis before, if nothing it read changed. */
|
|
149
|
+
reuse(base) {
|
|
150
|
+
const final = this.reuseFinal;
|
|
151
|
+
if (final === undefined) {
|
|
152
|
+
return undefined;
|
|
153
|
+
}
|
|
154
|
+
this.reuseFinal = undefined;
|
|
155
|
+
const files = this.ast.ast.files;
|
|
156
|
+
const dfData = {
|
|
157
|
+
...base,
|
|
158
|
+
environment: final.df.environment,
|
|
159
|
+
cds: undefined,
|
|
160
|
+
referenceChain: [files[0].filePath],
|
|
161
|
+
statementOrder: new Map(),
|
|
162
|
+
unreachable: new Set()
|
|
163
|
+
};
|
|
164
|
+
this.restore(final, dfData);
|
|
165
|
+
final.df.graph.setIdMap(this.ast.idMap);
|
|
166
|
+
this.applied = true;
|
|
167
|
+
let df = final.df;
|
|
168
|
+
for (let i = this.reuseFrom; i < this.initialFiles; i++) {
|
|
169
|
+
df = (0, built_in_source_1.standaloneSourceFile)(i, files[i], dfData, df);
|
|
170
|
+
}
|
|
171
|
+
return { df, dfData };
|
|
172
|
+
}
|
|
173
|
+
resume(fileIndex, info) {
|
|
174
|
+
const data = info;
|
|
175
|
+
if (fileIndex !== 0) {
|
|
176
|
+
return undefined;
|
|
177
|
+
}
|
|
178
|
+
/* the list wraps its statements as arguments before it starts, which every analysis does anew, so these do not count as added by a statement */
|
|
179
|
+
this.listNodes = data.completeAst.idMap.size;
|
|
180
|
+
const from = this.resumeFrom;
|
|
181
|
+
if (from === undefined) {
|
|
182
|
+
return undefined;
|
|
183
|
+
}
|
|
184
|
+
this.resumeFrom = undefined;
|
|
185
|
+
this.restore(from, data);
|
|
186
|
+
from.list.graph.setIdMap(data.completeAst.idMap);
|
|
187
|
+
this.applied = true;
|
|
188
|
+
const total = data.completeAst.ast.files[0].root.children.length;
|
|
189
|
+
if (this.wants(from.list.count, total)) {
|
|
190
|
+
this.record(fileIndex, from.list, data);
|
|
191
|
+
}
|
|
192
|
+
return from.list;
|
|
193
|
+
}
|
|
194
|
+
wants(count, total) {
|
|
195
|
+
const last = Math.min(this.after, total);
|
|
196
|
+
return this.resumes && this.initialFiles === 1 && total >= this.minimum && count > last - this.keep && count <= last;
|
|
197
|
+
}
|
|
198
|
+
record(fileIndex, list, info) {
|
|
199
|
+
const data = info;
|
|
200
|
+
if (fileIndex !== 0) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
/* resuming the list only needs where the statements before passed on the control flow, not all they computed */
|
|
204
|
+
const cfg = { ...list, processed: list.processed.map(cfgOf), defaultReturn: cfgOf(list.defaultReturn) };
|
|
205
|
+
this.recorded.push(this.stateOf({ list: cfg }, data, list.environment.current, this.listNodes));
|
|
206
|
+
}
|
|
207
|
+
/** The state to continue the analysis from: a copy of `changing` and of whatever else the analysis goes on to change, with what it added so far. */
|
|
208
|
+
stateOf(changing, data, environment, before) {
|
|
209
|
+
return {
|
|
210
|
+
...this.copy({ ...changing, statementOrder: data.statementOrder, unreachable: data.unreachable }, data),
|
|
211
|
+
marks: marksOf(environment),
|
|
212
|
+
addedNodes: nodesAddedSince(data.completeAst.idMap, before),
|
|
213
|
+
addedFiles: data.completeAst.ast.files.slice(this.initialFiles),
|
|
214
|
+
considered: this.ctx.files.consideredFilesList().slice(this.initialRead).map(p => [p, contentOf(this.ctx, p)]),
|
|
215
|
+
config: this.stableConfig()
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
/** A copy that shares what the analysis never changes in place: the AST, the built-in environment, and frozen frames. */
|
|
219
|
+
copy(state, data) {
|
|
220
|
+
const idMap = data.completeAst.idMap;
|
|
221
|
+
/* the sourced files are known by identity, a file sourced again is analyzed again */
|
|
222
|
+
const files = new Set(data.completeAst.ast.files);
|
|
223
|
+
/* a live frame is handed to the copy and forks on its owner's next write, so it costs nothing to copy */
|
|
224
|
+
const shared = new Set();
|
|
225
|
+
return (0, objects_1.deepCloneSharing)(state, o => {
|
|
226
|
+
/* most of what a copy meets are plain records (edges, vertices, references), so these are asked first */
|
|
227
|
+
if (Object.getPrototypeOf(o) === Object.prototype) {
|
|
228
|
+
return o === this.config || files.has(o) || isNodeOf(o, idMap);
|
|
229
|
+
}
|
|
230
|
+
else if (o instanceof environment_1.Environment) {
|
|
231
|
+
if (o.builtInEnv === true) {
|
|
232
|
+
return true;
|
|
233
|
+
}
|
|
234
|
+
shared.add(o.shareMemory());
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
return o === idMap || o instanceof frame_memory_1.LazyBindings || (o instanceof frame_memory_1.Frame && (o.isFrozen || shared.has(o)));
|
|
238
|
+
}, clonedFieldsOf);
|
|
239
|
+
}
|
|
240
|
+
restore(state, data) {
|
|
241
|
+
if (state.statementOrder !== undefined) {
|
|
242
|
+
for (const [id, span] of state.statementOrder) {
|
|
243
|
+
data.statementOrder?.set(id, span);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
if (state.unreachable !== undefined) {
|
|
247
|
+
for (const id of state.unreachable) {
|
|
248
|
+
data.unreachable?.add(id);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
restoreMarks(data.environment.current, state.marks);
|
|
252
|
+
this.addAgain(state, data.completeAst);
|
|
253
|
+
}
|
|
254
|
+
/** Adds what the analysis before added to the AST and the context again, which a continued analysis does not do itself. */
|
|
255
|
+
addAgain(added, ast) {
|
|
256
|
+
for (const [id, node] of added.addedNodes) {
|
|
257
|
+
/* an id added for a node of the AST names the node this AST holds for it */
|
|
258
|
+
ast.idMap.set(id, ast.idMap.get(node.info.id) ?? node);
|
|
259
|
+
}
|
|
260
|
+
const files = ast.ast.files;
|
|
261
|
+
for (const file of added.addedFiles) {
|
|
262
|
+
if (!files.some(f => f.filePath === file.filePath)) {
|
|
263
|
+
files.push(file);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
for (const [path] of added.considered) {
|
|
267
|
+
this.ctx.files.addConsideredFile(path);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
/** Hands out the finalized analysis before again if the program did not change, which skips the analysis altogether. */
|
|
271
|
+
reuseFinalized() {
|
|
272
|
+
const finalized = this.previous?.finalized;
|
|
273
|
+
if (!this.reuses || this.update === undefined || !flowr_analyzer_incremental_dataflow_update_type_plugin_1.IncrementalUpdate.unchanged(this.update) || finalized === undefined || !this.holds(finalized)) {
|
|
274
|
+
return undefined;
|
|
275
|
+
}
|
|
276
|
+
this.addAgain(finalized, this.ast);
|
|
277
|
+
finalized.df.graph.setIdMap(this.ast.idMap);
|
|
278
|
+
this.ctx.inc.storeAppliedIncrementalUpdate({ ...this.update, applied: true });
|
|
279
|
+
this.ctx.inc.storeDataflowSnapshot({ ...this.previous, files: this.files, finalized });
|
|
280
|
+
return finalized.df;
|
|
281
|
+
}
|
|
282
|
+
/** Keeps the finalized `df` for {@link reuseFinalized}, and hands it back. */
|
|
283
|
+
finalized(df) {
|
|
284
|
+
if (this.reuses && this.stored !== undefined) {
|
|
285
|
+
const requested = new Set(this.files.map(f => f.filePath));
|
|
286
|
+
this.ctx.inc.storeDataflowSnapshot({ ...this.stored, finalized: {
|
|
287
|
+
df,
|
|
288
|
+
addedNodes: nodesAddedSince(this.ast.idMap, this.initialNodes),
|
|
289
|
+
addedFiles: this.ast.ast.files.slice(this.initialFiles),
|
|
290
|
+
considered: this.ctx.files.consideredFilesList().slice(this.initialRead).filter(p => !requested.has(p)).map(p => [p, contentOf(this.ctx, p)]),
|
|
291
|
+
config: this.stableConfig()
|
|
292
|
+
} });
|
|
293
|
+
}
|
|
294
|
+
return df;
|
|
295
|
+
}
|
|
296
|
+
/** Keeps what the next analysis may continue from, unless the analysis was cut short. */
|
|
297
|
+
end(result) {
|
|
298
|
+
if (this.update !== undefined) {
|
|
299
|
+
this.ctx.inc.storeAppliedIncrementalUpdate({ ...this.update, applied: this.applied });
|
|
300
|
+
}
|
|
301
|
+
if (gas_1.activeDataflowBudget?.exhausted !== undefined) {
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
const checkpoints = [...this.carried, ...this.recorded].sort((a, b) => a.list.count - b.list.count);
|
|
305
|
+
const final = this.resumes && this.initialFiles > 1 ? this.stateOf({ df: result.df }, result.dfData, result.df.environment.current, this.initialNodes) : undefined;
|
|
306
|
+
this.stored = { files: this.files, checkpoints, final };
|
|
307
|
+
this.ctx.inc.storeDataflowSnapshot(this.stored);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Helper functions of the incremental dataflow analysis, which continues the analysis before it where the files did not change.
|
|
312
|
+
* The dataflow analysis {@link IncrementalDataflow.begin|begins} a session, which may {@link IncrementalDataflowSession#reuse|reuse} a complete earlier analysis,
|
|
313
|
+
* or hands itself to the processors as their {@link DataflowProcessorInformation#checkpoints|checkpoints} to resume the top-level statements of a file after
|
|
314
|
+
* those that did not change.
|
|
315
|
+
* Either way, it {@link IncrementalDataflowSession#end|ends} before the dataflow is finalized, keeping copies of what the next analysis may continue from.
|
|
316
|
+
*/
|
|
317
|
+
exports.IncrementalDataflow = {
|
|
318
|
+
name: 'IncrementalDataflow',
|
|
319
|
+
/**
|
|
320
|
+
* Begins an incremental dataflow analysis of `ast`, before the analysis adds the files it sources, as the {@link FlowrAnalyzerIncrementalDataflowHeuristicPlugin} plans it
|
|
321
|
+
* for how the files changed; `undefined` if it plans neither to reuse nor to resume, and no analysis before kept its files to compare with.
|
|
322
|
+
*/
|
|
323
|
+
begin(ast, ctx) {
|
|
324
|
+
const previous = ctx.inc.takeDataflowSnapshot();
|
|
325
|
+
const update = previous === undefined ? undefined : ctx.inc.determineUpdateTypes(previous.files, ast, ctx);
|
|
326
|
+
const plan = ctx.inc.planDataflow(ctx, update);
|
|
327
|
+
return plan.reuse || plan.checkpoints > 0 || update !== undefined ? new IncrementalDataflowSession(ast, ctx, previous, update, plan) : undefined;
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
//# sourceMappingURL=incremental-dataflow.js.map
|
|
@@ -49,7 +49,20 @@ export declare enum PluginType {
|
|
|
49
49
|
* Multiple Gas plugins are combined by taking the maximum level returned.
|
|
50
50
|
* @see {@link FlowrAnalyzerGasPlugin} - for the base class to implement such a plugin.
|
|
51
51
|
*/
|
|
52
|
-
Gas = "gas"
|
|
52
|
+
Gas = "gas",
|
|
53
|
+
/**
|
|
54
|
+
* Plugins that classifies the {@link IncrementalUpdateType}, so the dataflow analysis can be
|
|
55
|
+
* patched incrementally instead of fully recomputed. At most one may be registered; the default
|
|
56
|
+
* plugin runs otherwise.
|
|
57
|
+
* @see {@link FlowrAnalyzerIncrementalDataflowUpdateTypePlugin} - for the base class to implement such a plugin.
|
|
58
|
+
*/
|
|
59
|
+
IncrementalDataflowUpdateType = "incremental-dataflow-update-type",
|
|
60
|
+
/**
|
|
61
|
+
* Plugins that plan how a dataflow analysis builds on the one before (reuse it, resume from checkpoints, or start over).
|
|
62
|
+
* At most one may be registered; the plugin following the configuration runs otherwise.
|
|
63
|
+
* @see {@link FlowrAnalyzerIncrementalDataflowHeuristicPlugin} - for the base class to implement such a plugin.
|
|
64
|
+
*/
|
|
65
|
+
IncrementalDataflowHeuristic = "incremental-dataflow-heuristic"
|
|
53
66
|
}
|
|
54
67
|
/**
|
|
55
68
|
* This is the main interface that every plugin to be used with the {@link FlowrAnalyzer} must comply with.
|
|
@@ -89,7 +102,14 @@ export declare abstract class FlowrAnalyzerPlugin<In = unknown, Out extends Asyn
|
|
|
89
102
|
abstract readonly type: PluginType;
|
|
90
103
|
/** Returns a default/dummy implementation to be used when no plugin of this type is registered or triggered. */
|
|
91
104
|
static defaultPlugin(): FlowrAnalyzerPlugin<unknown, unknown>;
|
|
92
|
-
/**
|
|
105
|
+
/**
|
|
106
|
+
* Optional Hook to create deep copies of a Plugin for analyzer forks
|
|
107
|
+
* If not implemented forking an analyzer will copy by reference
|
|
108
|
+
*/
|
|
109
|
+
fork?(): FlowrAnalyzerPlugin<In, Out>;
|
|
110
|
+
/**
|
|
111
|
+
* Run the plugin with the given context and arguments.
|
|
112
|
+
*/
|
|
93
113
|
processor(context: FlowrAnalyzerContext, args: In): Out;
|
|
94
114
|
protected abstract process(analyzer: FlowrAnalyzerContext, args: In): Out;
|
|
95
115
|
}
|