• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 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 '../../core/base/Stmt';
17import { Value } from '../../core/base/Value';
18import { ContextID } from '../pointerAnalysis/Context';
19import { FuncID } from './CallGraph';
20
21export type CallSiteID = number;
22
23export interface ICallSite {
24    callStmt: Stmt;
25    args: Value[] | undefined;
26    callerFuncID: FuncID;
27}
28
29export class CallSite implements ICallSite {
30    public callStmt: Stmt;
31    public args: Value[] | undefined;
32    public calleeFuncID: FuncID;
33    public callerFuncID: FuncID;
34
35    constructor(s: Stmt, a: Value[] | undefined, ce: FuncID, cr: FuncID) {
36        this.callStmt = s;
37        this.args = a;
38        this.calleeFuncID = ce;
39        this.callerFuncID = cr;
40    }
41}
42
43export class DynCallSite implements ICallSite {
44    public callStmt: Stmt;
45    public args: Value[] | undefined;
46    public protentialCalleeFuncID: FuncID | undefined;
47    public callerFuncID: FuncID;
48
49    constructor(s: Stmt, a: Value[] | undefined, ptcCallee: FuncID | undefined, caller: FuncID) {
50        this.callerFuncID = caller;
51        this.callStmt = s;
52        this.args = a;
53        this.protentialCalleeFuncID = ptcCallee;
54    }
55}
56
57export class CSCallSite extends CallSite {
58    public cid: ContextID;
59
60    constructor(id: ContextID, cs: CallSite) {
61        super(cs.callStmt, cs.args, cs.calleeFuncID, cs.callerFuncID);
62        this.cid = id;
63    }
64}