@eagleoutice/flowr 2.17.8 → 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 +11 -1
- package/config.js +45 -8
- 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 +5 -3
- package/project/plugins/plugin-registry.js +7 -2
- 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
|
@@ -32,6 +32,20 @@ class FlowrAnalyzerLoadingOrderContext extends abstract_flowr_analyzer_context_1
|
|
|
32
32
|
this.seen.clear();
|
|
33
33
|
this.rerunRequired = this.plugins.length > 0;
|
|
34
34
|
}
|
|
35
|
+
fork(source) {
|
|
36
|
+
this.unordered.push(...source.unordered);
|
|
37
|
+
this.seen.clear();
|
|
38
|
+
for (const request of source.seen) {
|
|
39
|
+
this.seen.add(request);
|
|
40
|
+
}
|
|
41
|
+
for (const guess of source.guesses) {
|
|
42
|
+
this.guesses.push([...guess]);
|
|
43
|
+
}
|
|
44
|
+
if (source.knownOrder) {
|
|
45
|
+
this.knownOrder = source.knownOrder.slice();
|
|
46
|
+
}
|
|
47
|
+
this.rerunRequired = source.rerunRequired;
|
|
48
|
+
}
|
|
35
49
|
/**
|
|
36
50
|
* Registers `request` as unordered unless the same one is already there, reporting whether it was new.
|
|
37
51
|
* Project discovery and the implicit-source scan reach the same file from both ends, so a file otherwise
|
|
@@ -89,6 +89,7 @@ export declare class FlowrAnalyzerMetaContext implements ReadOnlyFlowrAnalyzerMe
|
|
|
89
89
|
private readonly ensureContributed;
|
|
90
90
|
constructor(ensureContributed?: () => void);
|
|
91
91
|
reset(): void;
|
|
92
|
+
fork(source: FlowrAnalyzerMetaContext): void;
|
|
92
93
|
receive(event: InvalidationEvent): void;
|
|
93
94
|
/**
|
|
94
95
|
* Contribute what a source declares about the project; `undefined` fields are ignored, so a plugin can pass
|
|
@@ -35,6 +35,17 @@ class FlowrAnalyzerMetaContext {
|
|
|
35
35
|
reset() {
|
|
36
36
|
this.fields.clear();
|
|
37
37
|
}
|
|
38
|
+
fork(source) {
|
|
39
|
+
this.fields.clear();
|
|
40
|
+
source.fields.forEach((field, key) => {
|
|
41
|
+
this.fields.set(key, {
|
|
42
|
+
priority: field.priority,
|
|
43
|
+
value: Array.isArray(field.value)
|
|
44
|
+
? field.value.slice()
|
|
45
|
+
: field.value
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
}
|
|
38
49
|
receive(event) {
|
|
39
50
|
(0, flowr_cache_1.resetOnFullInvalidation)(this, event);
|
|
40
51
|
}
|
|
@@ -154,7 +154,8 @@ export declare class FlowrTextFile extends FlowrFile<string> {
|
|
|
154
154
|
*/
|
|
155
155
|
export declare class FlowrInlineTextFile extends FlowrFile<string> {
|
|
156
156
|
private contentStr;
|
|
157
|
-
constructor(path: PathLike, content: string);
|
|
157
|
+
constructor(path: PathLike, content: string, roles?: readonly FileRole[]);
|
|
158
|
+
copy(): FlowrInlineTextFile;
|
|
158
159
|
protected loadContent(): string;
|
|
159
160
|
/**
|
|
160
161
|
* Update the content of this inline file and invalidate the cache to trigger updates in the analysis.
|
|
@@ -148,10 +148,13 @@ exports.FlowrTextFile = FlowrTextFile;
|
|
|
148
148
|
*/
|
|
149
149
|
class FlowrInlineTextFile extends FlowrFile {
|
|
150
150
|
contentStr;
|
|
151
|
-
constructor(path, content) {
|
|
152
|
-
super(path);
|
|
151
|
+
constructor(path, content, roles) {
|
|
152
|
+
super(path, roles);
|
|
153
153
|
this.contentStr = content;
|
|
154
154
|
}
|
|
155
|
+
copy() {
|
|
156
|
+
return new FlowrInlineTextFile(this.path(), this.contentStr, this.roles);
|
|
157
|
+
}
|
|
155
158
|
loadContent() {
|
|
156
159
|
return this.contentStr;
|
|
157
160
|
}
|
|
@@ -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 };
|