• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 
16 #ifndef LIBARK_DEFECT_SCAN_AUX_INCLUDE_CLASS_H
17 #define LIBARK_DEFECT_SCAN_AUX_INCLUDE_CLASS_H
18 
19 #include <string>
20 #include <vector>
21 #include "libpandabase/macros.h"
22 
23 namespace panda::defect_scan_aux {
24 class Class;
25 class Function;
26 class AbcFile;
27 
28 struct ParentClassInfo {
29     const Class *class_ {nullptr};
30     std::string class_name_;
31     std::string external_module_name_;
32     std::string global_var_name_;
33 };
34 
35 class Class final {
36 public:
Class(std::string_view class_name,const AbcFile * abc_file,const Function * def_func)37     Class(std::string_view class_name, const AbcFile *abc_file, const Function *def_func)
38         : class_name_(class_name), abc_file_(abc_file), def_func_(def_func)
39     {
40     }
41     ~Class() = default;
42     NO_COPY_SEMANTIC(Class);
43     NO_MOVE_SEMANTIC(Class);
44 
45     const std::string &GetClassName() const;
46     const AbcFile *GetAbcFileInstance() const;
47     const Function *GetDefineFunction() const;
48     size_t GetMemberFunctionCount() const;
49     const Function *GetMemberFunctionByName(std::string_view func_name) const;
50     const Function *GetMemberFunctionByIndex(size_t index) const;
51     const Class *GetParentClass() const;
52     const std::string &GetParentClassName() const;
53     const std::string &GetParClassExternalModuleName() const;
54     const std::string &GetParClassGlobalVarName() const;
55 
56 private:
57     void SetParentClass(const Class *parent_class);
58     void SetParentClassName(std::string_view par_class_name);
59     void SetParClassExternalModuleName(std::string_view external_module_name);
60     void SetParClassGlobalVarName(std::string global_var_name);
61     void AddMemberFunction(const Function *func);
62 
63     std::string class_name_;
64     const AbcFile *abc_file_ {nullptr};
65     const Function *def_func_ {nullptr};
66     std::vector<const Function *> member_func_list_;
67     ParentClassInfo par_class_info_;
68 
69     friend class AbcFile;
70 };
71 }  // namespace panda::defect_scan_aux
72 #endif  // LIBARK_DEFECT_SCAN_AUX_INCLUDE_CLASS_H