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 LIBPANDAFILE_UTIL_COLLECT_UTIL_H 17 #define LIBPANDAFILE_UTIL_COLLECT_UTIL_H 18 19 #include <string> 20 #include <unordered_set> 21 #include "libpandafile/bytecode_instruction-inl.h" 22 #include "libpandafile/class_data_accessor-inl.h" 23 #include "libpandafile/code_data_accessor-inl.h" 24 #include "libpandafile/literal_data_accessor-inl.h" 25 26 namespace panda::libpandafile { 27 class CollectUtil { 28 public: 29 void CollectLiteralArray(const panda_file::File &file, std::unordered_set<uint32_t> &processed_ids); 30 31 private: 32 void CollectClassLiteralArray(panda_file::ClassDataAccessor &class_data_accessor, 33 std::unordered_set<uint32_t> &processed_ids, 34 std::unordered_set<uint32_t> &nest_unprocess_ids); 35 void ProcessNestLiteralArray(const panda_file::File &file_, std::unordered_set<uint32_t> &processed_ids, 36 std::unordered_set<uint32_t> &nest_unprocess_ids); 37 panda_file::File::EntityId GetLiteralArrayIdInBytecodeInst(const panda_file::File &file, 38 panda_file::File::EntityId method_id, 39 panda::BytecodeInst<BytecodeInstMode::FAST> bc_ins); 40 static constexpr std::string_view ES_MODULE_RECORD = "_ESModuleRecord;"; 41 static constexpr std::string_view ES_SCOPE_NAMES_RECORD = "_ESScopeNamesRecord"; 42 static constexpr std::string_view SCOPE_NAMES = "scopeNames"; 43 static constexpr std::string_view MODULE_RECORD_IDX = "moduleRecordIdx"; 44 static constexpr std::string_view MODULE_REQUEST_PHASE_IDX = "moduleRequestPhaseIdx"; 45 }; 46 } // namespace panda::libpandafile 47 #endif