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 ES2PANDA_EVALUATE_SCOPED_DEBUG_INFO_PLUGIN_INL_H 17#define ES2PANDA_EVALUATE_SCOPED_DEBUG_INFO_PLUGIN_INL_H 18 19#include "evaluate/scopedDebugInfoPlugin.h" 20 21namespace ark::es2panda::evaluate { 22 23template <bool IS_PROLOGUE> 24void ScopedDebugInfoPlugin::RegisterPrologueEpilogue(ir::BlockStatement *block, ir::Statement *stmt) 25{ 26 ASSERT(block); 27 ASSERT(stmt); 28 29 auto iter = prologueEpilogueMap_.find(block); 30 if (iter == prologueEpilogueMap_.end()) { 31 ArenaVector<ir::Statement *> vec(1, stmt, Allocator()->Adapter()); 32 if constexpr (IS_PROLOGUE) { 33 prologueEpilogueMap_.emplace(block, 34 std::make_pair(vec, ArenaVector<ir::Statement *>(Allocator()->Adapter()))); 35 } else { 36 prologueEpilogueMap_.emplace(block, 37 std::make_pair(ArenaVector<ir::Statement *>(Allocator()->Adapter()), vec)); 38 } 39 } else { 40 if constexpr (IS_PROLOGUE) { 41 iter->second.first.push_back(stmt); 42 } else { 43 iter->second.second.push_back(stmt); 44 } 45 } 46} 47 48} // namespace ark::es2panda::evaluate 49 50#endif // ES2PANDA_EVALUATE_SCOPED_DEBUG_INFO_PLUGIN_INL_H 51