• 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
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_GC_CREATE_GC()  \
38% Common::plugins.each do |plugin_lang, plugin_opts|
39% next unless plugin_opts["language_config"]
40    template GC *CreateGC< <%= plugin_lang.capitalize %>LanguageConfig >(GCType gc_type, ObjectAllocatorBase *object_allocator, const GCSettings &settings);  \
41% end
42    template GC *CreateGC< PandaAssemblyLanguageConfig >(GCType gc_type, ObjectAllocatorBase *object_allocator, const GCSettings &settings)
43
44#ifndef NDEBUG
45// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
46#define TEMPLATE_GC_IS_MUTATOR_ALLOWED() \
47% Common::plugins.each do |plugin_lang, plugin_opts|
48% next unless plugin_opts["language_config"]
49template<> bool GCLang<<%= plugin_lang.capitalize %>LanguageConfig>::IsMutatorAllowed() \
50{ \
51% if plugin_lang.eql? "ECMASCRIPT"
52    return GetPandaVm()->GetLanguageContext().GetLanguage() == panda_file::SourceLang::ECMASCRIPT || \
53    !IsGCRunning() || Locks::mutator_lock->HasLock(); \
54% else
55    return !IsGCRunning() || Locks::mutator_lock->HasLock(); \
56% end
57} \
58% end
59template<> bool GCLang<PandaAssemblyLanguageConfig>::IsMutatorAllowed() \
60{ \
61    return !IsGCRunning() || Locks::mutator_lock->HasLock(); \
62}
63#else
64// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
65#define TEMPLATE_GC_IS_MUTATOR_ALLOWED() \
66template <class LanguageConfig> \
67bool GCLang<LanguageConfig>::IsMutatorAllowed() \
68{ \
69    return false; \
70}
71#endif
72
73