1 /* 2 * Copyright (c) 2021-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 PANDA_ASSEMBLER_ASSEMBLY_PROGRAM_H 17 #define PANDA_ASSEMBLER_ASSEMBLY_PROGRAM_H 18 19 #include <string> 20 #include <unordered_set> 21 22 #include "assembly-function.h" 23 #include "assembly-record.h" 24 #include "assembly-type.h" 25 #include "assembly-methodhandle.h" 26 #include "assembly-literals.h" 27 #include "extensions/extensions.h" 28 #include "macros.h" 29 30 namespace ark::pandasm { 31 32 // NOLINTBEGIN(misc-non-private-member-variables-in-classes) 33 struct Program { 34 using StringT = std::set<std::string>; 35 36 ark::panda_file::SourceLang lang {ark::panda_file::SourceLang::PANDA_ASSEMBLY}; 37 std::map<std::string, ark::pandasm::Record> recordTable; 38 std::map<std::string, ark::pandasm::Function> functionTable; 39 std::unordered_map<std::string, std::vector<std::string>> 40 functionSynonyms; // we might keep unordered, since we don't iterate over it 41 std::map<std::string, ark::pandasm::LiteralArray> literalarrayTable; 42 StringT strings; 43 std::set<Type> arrayTypes; 44 45 /* 46 * Returns a JSON string with the program structure and scopes locations 47 */ 48 PANDA_PUBLIC_API std::string JsonDump() const; 49 }; 50 // NOLINTEND(misc-non-private-member-variables-in-classes) 51 52 } // namespace ark::pandasm 53 54 #endif // PANDA_ASSEMBLER_ASSEMBLY_PROGRAM_H 55