• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
16% Common::plugins.each do |plugin_lang, plugin_opts|
17% next unless plugin_opts["language_config"]
18class <%= plugin_lang.capitalize %>LanguageConfig {
19public:
20    static constexpr panda_file::SourceLang LANG = <%= plugin_opts["lang_enum"] %>;
21    static constexpr LangTypeT LANG_TYPE = LANG_TYPE_<%= plugin_opts["language_config"]["lang_type"].upcase %>;
22    static constexpr MTModeT MT_MODE = MT_MODE_<%= plugin_opts["language_config"]["mt_mode"].upcase %>;
23    static constexpr bool HAS_VALUE_OBJECT_TYPES = <%= plugin_opts["language_config"]["has_value_object_types"].downcase %>;
24};
25
26% end
27
28// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
29#define TEMPLATE_CLASS_LANGUAGE_CONFIG(x)  \
30% Common::plugins.each do |plugin_lang, plugin_opts|
31% next unless plugin_opts["language_config"]
32    template class x< <%= plugin_lang.capitalize %>LanguageConfig >; \
33% end
34    template class x< PandaAssemblyLanguageConfig >
35
36// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
37#define TEMPLATE_CLASS_LANGUAGE_CONFIG_AND_ARGS(x, ...)  \
38% Common::plugins.each do |plugin_lang, plugin_opts|
39% next unless plugin_opts["language_config"]
40    template class x< <%= plugin_lang.capitalize %>LanguageConfig , __VA_ARGS__ >; \
41% end
42    template class x< PandaAssemblyLanguageConfig, __VA_ARGS__ >
43
44// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
45#define TEMPLATE_GC_CREATE_GC()  \
46% Common::plugins.each do |plugin_lang, plugin_opts|
47% next unless plugin_opts["language_config"]
48    template GC *CreateGC< <%= plugin_lang.capitalize %>LanguageConfig >(GCType gc_type, ObjectAllocatorBase *object_allocator, const GCSettings &settings);  \
49% end
50    template GC *CreateGC< PandaAssemblyLanguageConfig >(GCType gc_type, ObjectAllocatorBase *object_allocator, const GCSettings &settings)
51
52#ifndef NDEBUG
53// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
54#define TEMPLATE_GC_IS_MUTATOR_ALLOWED() \
55% Common::plugins.each do |plugin_lang, plugin_opts|
56% next unless plugin_opts["language_config"]
57template<> bool GCLang<<%= plugin_lang.capitalize %>LanguageConfig>::IsMutatorAllowed() \
58{ \
59    return !IsGCRunning() || PandaVM::GetCurrent()->GetMutatorLock()->HasLock(); \
60} \
61% end
62template<> bool GCLang<PandaAssemblyLanguageConfig>::IsMutatorAllowed() \
63{ \
64    return !IsGCRunning() || PandaVM::GetCurrent()->GetMutatorLock()->HasLock(); \
65}
66#else
67// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
68#define TEMPLATE_GC_IS_MUTATOR_ALLOWED() \
69template <class LanguageConfig> \
70bool GCLang<LanguageConfig>::IsMutatorAllowed() \
71{ \
72    return false; \
73}
74#endif
75
76