UNPKG

@eagleoutice/flowr

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

59 lines (58 loc) 3.83 kB
import type { CfgBasicBlockVertex, CfgSimpleVertex, ControlFlowInformation } from '../../control-flow/control-flow-graph'; import type { SemanticCfgGuidedVisitorConfiguration } from '../../control-flow/semantic-cfg-guided-visitor'; import { SemanticCfgGuidedVisitor } from '../../control-flow/semantic-cfg-guided-visitor'; import type { DataflowGraph } from '../../dataflow/graph/graph'; import type { DataflowGraphVertexFunctionCall, DataflowGraphVertexVariableDefinition } from '../../dataflow/graph/vertex'; import type { NoInfo } from '../../r-bridge/lang-4.x/ast/model/model'; import type { NormalizedAst } from '../../r-bridge/lang-4.x/ast/model/processing/decorate'; import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id'; import { type AbstractInterpretationInfo } from './absint-info'; export type DataFrameShapeInferenceVisitorConfiguration<OtherInfo = NoInfo, ControlFlow extends ControlFlowInformation = ControlFlowInformation, Ast extends NormalizedAst<OtherInfo & AbstractInterpretationInfo> = NormalizedAst<OtherInfo & AbstractInterpretationInfo>, Dfg extends DataflowGraph = DataflowGraph> = Omit<SemanticCfgGuidedVisitorConfiguration<OtherInfo & AbstractInterpretationInfo, ControlFlow, Ast, Dfg>, 'defaultVisitingOrder' | 'defaultVisitingType'>; /** * The control flow graph visitor to infer the shape of data frames using abstract interpretation */ export declare class DataFrameShapeInferenceVisitor<OtherInfo = NoInfo, ControlFlow extends ControlFlowInformation = ControlFlowInformation, Ast extends NormalizedAst<OtherInfo & AbstractInterpretationInfo> = NormalizedAst<OtherInfo & AbstractInterpretationInfo>, Dfg extends DataflowGraph = DataflowGraph, Config extends DataFrameShapeInferenceVisitorConfiguration<OtherInfo, ControlFlow, Ast, Dfg> = DataFrameShapeInferenceVisitorConfiguration<OtherInfo, ControlFlow, Ast, Dfg>> extends SemanticCfgGuidedVisitor<OtherInfo & AbstractInterpretationInfo, ControlFlow, Ast, Dfg, Config & { defaultVisitingOrder: 'forward'; defaultVisitingType: 'exit'; }> { /** * The old domain of an AST node before processing the node retrieved from the attached {@link AbstractInterpretationInfo}. * This is used to check whether the state has changed and successors should be visited again, and is also required for widening. */ private oldDomain; /** * The new domain of an AST node during and after processing the node. * This information is stored in the {@link AbstractInterpretationInfo} afterwards. */ private newDomain; constructor(config: Config); protected visitNode(nodeId: NodeId): boolean; protected visitDataflowNode(vertex: Exclude<CfgSimpleVertex, CfgBasicBlockVertex>): void; protected onVariableDefinition({ vertex }: { vertex: DataflowGraphVertexVariableDefinition; }): void; protected onAssignmentCall({ call, target, source }: { call: DataflowGraphVertexFunctionCall; target?: NodeId; source?: NodeId; }): void; protected onAccessCall({ call }: { call: DataflowGraphVertexFunctionCall; }): void; protected onDefaultFunctionCall({ call }: { call: DataflowGraphVertexFunctionCall; }): void; protected onReplacementCall({ call, source, target }: { call: DataflowGraphVertexFunctionCall; source: NodeId | undefined; target: NodeId | undefined; }): void; private applyDataFrameAssignment; private applyDataFrameExpression; /** We only process vertices of leaf nodes and exit vertices (no entry nodes of complex nodes) */ private shouldSkipVertex; /** Get all AST nodes for the predecessor vertices that are leaf nodes and exit vertices */ private getPredecessorNodes; private shouldWiden; private clearUnassignedInfo; }