/*
 * Copyright (c) 2021-2024 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

class EtsLanguageConfig {
public:
    static constexpr panda_file::SourceLang LANG = ark::SourceLanguage::ETS;
    static constexpr LangTypeT LANG_TYPE = LANG_TYPE_STATIC;
    static constexpr MTModeT MT_MODE = MT_MODE_TASK;
    static constexpr bool HAS_VALUE_OBJECT_TYPES = false;
};


// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define TEMPLATE_CLASS_LANGUAGE_CONFIG(x)  \
    template class x< EtsLanguageConfig >; \
    template class x< PandaAssemblyLanguageConfig >

// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define TEMPLATE_CLASS_LANGUAGE_CONFIG_AND_ARGS(x, ...)  \
    template class x< EtsLanguageConfig , __VA_ARGS__ >; \
    template class x< PandaAssemblyLanguageConfig, __VA_ARGS__ >

// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define TEMPLATE_GC_CREATE_GC()  \
    template GC *CreateGC< EtsLanguageConfig >(GCType gc_type, ObjectAllocatorBase *object_allocator, const GCSettings &settings);  \
    template GC *CreateGC< PandaAssemblyLanguageConfig >(GCType gc_type, ObjectAllocatorBase *object_allocator, const GCSettings &settings)

#ifndef NDEBUG
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define TEMPLATE_GC_IS_MUTATOR_ALLOWED() \
template<> bool GCLang<EtsLanguageConfig>::IsMutatorAllowed() \
{ \
    return !IsGCRunning() || PandaVM::GetCurrent()->GetMutatorLock()->HasLock(); \
} \
template<> bool GCLang<PandaAssemblyLanguageConfig>::IsMutatorAllowed() \
{ \
    return !IsGCRunning() || PandaVM::GetCurrent()->GetMutatorLock()->HasLock(); \
}
#else
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define TEMPLATE_GC_IS_MUTATOR_ALLOWED() \
template <class LanguageConfig> \
bool GCLang<LanguageConfig>::IsMutatorAllowed() \
{ \
    return false; \
}
#endif

