1/* 2 * Copyright (c) 2024-2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16import { Stmt } from '../base/Stmt'; 17import { ArkMethod } from '../model/ArkMethod'; 18 19export abstract class DataflowProblem<D> { 20 /** 21 * Transfer the outFact of srcStmt to the inFact of tgtStmt 22 * 23 * Return true if keeping progagation (i.e., tgtStmt will be added to the WorkList for further analysis) 24 */ 25 /* 26 abstract transferNormalEdge(srcStmt: Stmt, tgtStmt: Stmt, result: DataflowResult): boolean; 27 28 abstract transferCallToReturnEdge(srcStmt: Stmt, tgtStmt: Stmt, result: DataflowResult): boolean; 29 30 abstract transferCallEdge(srcStmt: Stmt, tgtStmt: Stmt, result: DataflowResult): boolean; 31 32 abstract transferReturnEdge(srcStmt: Stmt, tgtStmt: Stmt, result: DataflowResult): boolean; 33 */ 34 35 abstract getNormalFlowFunction(srcStmt: Stmt, tgtStmt: Stmt): FlowFunction<D>; 36 37 abstract getCallFlowFunction(srcStmt: Stmt, method: ArkMethod): FlowFunction<D>; 38 39 abstract getExitToReturnFlowFunction(srcStmt: Stmt, tgtStmt: Stmt, callStmt: Stmt): FlowFunction<D>; 40 41 abstract getCallToReturnFlowFunction(srcStmt: Stmt, tgtStmt: Stmt): FlowFunction<D>; 42 43 abstract createZeroValue(): D; 44 45 abstract getEntryPoint(): Stmt; 46 47 abstract getEntryMethod(): ArkMethod; 48 49 abstract factEqual(d1: D, d2: D): boolean; 50} 51 52export interface FlowFunction<D> { 53 getDataFacts(d: D): Set<D>; 54} 55