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 #ifndef PANDA_RUNTIME_ITABLE_BUILDER_H_ 16 #define PANDA_RUNTIME_ITABLE_BUILDER_H_ 17 18 #include "libpandabase/macros.h" 19 #include "libpandafile/class_data_accessor-inl.h" 20 #include "runtime/include/class-inl.h" 21 #include "runtime/include/mem/panda_smart_pointers.h" 22 23 namespace ark { 24 25 class ClassLinker; 26 27 class ITableBuilder { 28 public: 29 ITableBuilder() = default; 30 31 [[nodiscard]] virtual bool Build(ClassLinker *classLinker, Class *base, Span<Class *> classInterfaces, 32 bool isInterface) = 0; 33 34 [[nodiscard]] virtual bool Resolve(Class *klass) = 0; 35 36 virtual void UpdateClass(Class *klass) = 0; 37 38 virtual void DumpITable(Class *klass) = 0; 39 40 virtual ITable GetITable() const = 0; 41 42 virtual ~ITableBuilder() = default; 43 44 NO_COPY_SEMANTIC(ITableBuilder); 45 NO_MOVE_SEMANTIC(ITableBuilder); 46 }; 47 48 class DummyITableBuilder final : public ITableBuilder { 49 public: Build(ClassLinker * classLinker,Class * base,Span<Class * > classInterfaces,bool isInterface)50 bool Build([[maybe_unused]] ClassLinker *classLinker, [[maybe_unused]] Class *base, 51 [[maybe_unused]] Span<Class *> classInterfaces, [[maybe_unused]] bool isInterface) override 52 { 53 return true; 54 } 55 Resolve(Class * klass)56 bool Resolve([[maybe_unused]] Class *klass) override 57 { 58 return true; 59 } 60 UpdateClass(Class * klass)61 void UpdateClass([[maybe_unused]] Class *klass) override {} 62 DumpITable(Class * klass)63 void DumpITable([[maybe_unused]] Class *klass) override {} 64 GetITable()65 ITable GetITable() const override 66 { 67 return ITable(); 68 } 69 }; 70 71 } // namespace ark 72 73 #endif // PANDA_RUNTIME_ITABLE_BUILDER_H_ 74