1 /* 2 * Copyright (c) 2021 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_RUNTIME_MEM_GC_GC_EXTENSION_DATA_H_ 17 #define PANDA_RUNTIME_MEM_GC_GC_EXTENSION_DATA_H_ 18 19 #include "macros.h" 20 #include "runtime/include/language_config.h" 21 22 namespace panda::mem { 23 24 // Base class for all GC language-specific data holders. 25 // Can be extended for different language types. 26 class GCExtensionData { 27 public: 28 GCExtensionData() = default; 29 virtual ~GCExtensionData() = default; 30 NO_COPY_SEMANTIC(GCExtensionData); 31 NO_MOVE_SEMANTIC(GCExtensionData); 32 33 #ifndef NDEBUG GetLangType()34 LangTypeT GetLangType() 35 { 36 return type_; 37 } 38 39 protected: SetLangType(LangTypeT type)40 void SetLangType(LangTypeT type) 41 { 42 type_ = type; 43 } 44 45 private: 46 // Used for assertions in inherited classes to ensure that 47 // language extension got the corresponding type of data 48 LangTypeT type_ {LANG_TYPE_STATIC}; 49 #endif // NDEBUG 50 }; 51 52 } // namespace panda::mem 53 54 #endif // PANDA_RUNTIME_MEM_GC_GC_EXTENSION_DATA_H_ 55