@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
96 lines (95 loc) • 5.58 kB
TypeScript
import type { KnownParser } from '../../r-bridge/parser';
import { type CacheInvalidationEvent, FlowrCache } from './flowr-cache';
import { type DEFAULT_DATAFLOW_PIPELINE, type TREE_SITTER_DATAFLOW_PIPELINE } from '../../core/steps/pipeline/default-pipelines';
import type { IdGenerator } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
import type { NoInfo } from '../../r-bridge/lang-4.x/ast/model/model';
import type { TreeSitterExecutor } from '../../r-bridge/lang-4.x/tree-sitter/tree-sitter-executor';
import type { PipelineOutput } from '../../core/steps/pipeline/pipeline';
import type { CfgSimplificationPassName } from '../../control-flow/cfg-simplification';
import type { ControlFlowInformation } from '../../control-flow/control-flow-graph';
import type { CfgKind } from '../cfg-kind';
import type { FlowrAnalyzerContext } from '../context/flowr-analyzer-context';
import { CallGraph } from '../../dataflow/graph/call-graph';
interface FlowrAnalyzerCacheOptions<Parser extends KnownParser> {
parser: Parser;
context: FlowrAnalyzerContext;
getId?: IdGenerator<NoInfo>;
}
export type AnalyzerCacheType<Parser extends KnownParser> = Parser extends TreeSitterExecutor ? Partial<PipelineOutput<typeof TREE_SITTER_DATAFLOW_PIPELINE>> : Partial<PipelineOutput<typeof DEFAULT_DATAFLOW_PIPELINE>>;
/**
* This provides the full analyzer caching layer, please avoid using this directly
* and prefer the {@link FlowrAnalyzer}.
*/
export declare class FlowrAnalyzerCache<Parser extends KnownParser> extends FlowrCache<AnalyzerCacheType<Parser>> {
private args;
private pipeline;
private controlFlowCache;
private callGraphCache;
protected constructor(args: FlowrAnalyzerCacheOptions<Parser>);
private initCacheProviders;
static create<Parser extends KnownParser>(data: FlowrAnalyzerCacheOptions<Parser>): FlowrAnalyzerCache<Parser>;
receive(event: CacheInvalidationEvent): void;
private get;
reset(): void;
private runTapeUntil;
/**
* Get the parse output for the request, parsing if necessary.
* @param force - Do not use the cache, instead force a new parse.
* @see {@link FlowrAnalyzerCache#peekParse} - to get the parse output if already available without triggering a new parse.
*/
parse(force?: boolean): Promise<NonNullable<AnalyzerCacheType<Parser>['parse']>>;
/**
* Get the parse output for the request if already available, otherwise return `undefined`.
* This will not trigger a new parse.
* @see {@link FlowrAnalyzerCache#parse} - to get the parse output, parsing if necessary.
*/
peekParse(): NonNullable<AnalyzerCacheType<Parser>['parse']> | undefined;
/**
* Get the normalized abstract syntax tree for the request, normalizing if necessary.
* @param force - Do not use the cache, instead force new analyses.
* @see {@link FlowrAnalyzerCache#peekNormalize} - to get the normalized AST if already available without triggering a new normalization.
*/
normalize(force?: boolean): Promise<NonNullable<AnalyzerCacheType<Parser>['normalize']>>;
/**
* Get the normalized abstract syntax tree for the request if already available, otherwise return `undefined`.
* This will not trigger a new normalization.
* @see {@link FlowrAnalyzerCache#normalize} - to get the normalized AST, normalizing if necessary.
*/
peekNormalize(): NonNullable<AnalyzerCacheType<Parser>['normalize']> | undefined;
/**
* Get the dataflow graph for the request, computing if necessary.
* @param force - Do not use the cache, instead force new analyses.
* @see {@link FlowrAnalyzerCache#peekDataflow} - to get the dataflow graph if already available without triggering a new computation.
*/
dataflow(force?: boolean): Promise<NonNullable<AnalyzerCacheType<Parser>['dataflow']>>;
/**
* Get the dataflow graph for the request if already available, otherwise return `undefined`.
* This will not trigger a new computation.
* @see {@link FlowrAnalyzerCache#dataflow} - to get the dataflow graph, computing if necessary.
*/
peekDataflow(): NonNullable<AnalyzerCacheType<Parser>['dataflow']> | undefined;
/**
* Get the control flow graph (CFG) for the request, computing if necessary.
* @param force - Do not use the cache, instead force new analyses.
* @param kind - The kind of CFG that is requested.
* @param simplifications - Simplification passes to be applied to the CFG.
*/
controlflow(force: boolean | undefined, kind: CfgKind, simplifications?: readonly CfgSimplificationPassName[]): Promise<ControlFlowInformation>;
/**
* Get the control flow graph (CFG) for the request if already available, otherwise return `undefined`.
* @param kind - The kind of CFG that is requested.
* @param simplifications - Simplification passes to be applied to the CFG.
* @see {@link FlowrAnalyzerCache#controlflow} - to get the control flow graph, computing if necessary.
*/
peekControlflow(kind: CfgKind, simplifications: readonly CfgSimplificationPassName[] | undefined): ControlFlowInformation | undefined;
/**
* Get the call graph for the request, computing if necessary.
* @param force - Do not use the cache, instead force new analyses.
*/
callGraph(force?: boolean): Promise<CallGraph>;
/**
* Get the call graph for the request if already available, otherwise return `undefined`.
*/
peekCallGraph(): CallGraph | undefined;
}
export {};