1 /** 2 * Copyright (c) 2024 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 ABC2PROGRAM_ABC2PROGRAM_KEY_DATA_H 17 #define ABC2PROGRAM_ABC2PROGRAM_KEY_DATA_H 18 19 #include <string> 20 #include <map> 21 #include <assembly-program.h> 22 #include "file.h" 23 #include "abc_string_table.h" 24 25 namespace ark::abc2program { 26 27 using ExternalFieldTable = std::map<std::string, std::vector<pandasm::Field>>; 28 using NameToIdTable = std::map<std::string, panda_file::File::EntityId>; 29 30 class Abc2ProgramKeyData { 31 public: Abc2ProgramKeyData(const panda_file::File & file,AbcStringTable & stringTable,pandasm::Program & program)32 Abc2ProgramKeyData(const panda_file::File &file, AbcStringTable &stringTable, pandasm::Program &program) 33 : file_(file), stringTable_(stringTable), program_(program) 34 { 35 } 36 const panda_file::File &GetAbcFile() const; 37 std::map<panda_file::File::EntityId, const pandasm::Function *> GetFunctionTable(); 38 ExternalFieldTable &GetExternalFieldTable(); 39 NameToIdTable &GetMethodNameToIdTable(); 40 NameToIdTable &GetRecordNameToIdTable(); 41 AbcStringTable &GetAbcStringTable() const; 42 pandasm::Program &GetProgram() const; 43 std::string GetFullRecordNameById(const panda_file::File::EntityId &classId) const; 44 std::string GetFullFunctionNameById(const panda_file::File::EntityId &methodId) const; 45 ark::panda_file::SourceLang GetFileLanguage() const; 46 void SetFileLanguage(ark::panda_file::SourceLang language); 47 48 private: 49 inline bool IsSystemType(const std::string &typeName) const; 50 51 ExternalFieldTable externalFieldTable_ {}; 52 std::map<std::string, panda_file::File::EntityId> recordNameToId_ {}; 53 std::map<std::string, panda_file::File::EntityId> methodNameToId_ {}; 54 55 const panda_file::File &file_; 56 AbcStringTable &stringTable_; 57 pandasm::Program &program_; 58 ark::panda_file::SourceLang fileLanguage_ = panda_file::SourceLang::PANDA_ASSEMBLY; 59 }; // class Abc2ProgramKeyData 60 61 } // namespace ark::abc2program 62 63 #endif // ABC2PROGRAM_ABC2PROGRAM_KEY_DATA_H 64