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