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 16bool IsDynamicLanguage([[maybe_unused]] ark::panda_file::SourceLang lang) 17{ 18% Common::each_plugin_suboption("language_config", "lang_type") do |lang_type, _, plugin_opts| 19 if (lang == <%= plugin_opts["lang_enum"] %>) { 20 return <%= lang_type == "dynamic" %>; //NOLINT(readability-simplify-boolean-expr) 21 } 22% end 23 24 return false; 25} 26 27std::optional<ark::panda_file::SourceLang> LanguageFromString([[maybe_unused]] std::string_view lang) 28{ 29% Common::each_plugin_option "directive_name" do |directive_name, _, plugin_opts| 30 if (lang == "<%= directive_name %>") { 31 return <%= plugin_opts["lang_enum"] %>; 32 } 33% end 34 35 if (lang == "PandaAssembly") { 36 return ark::panda_file::SourceLang::PANDA_ASSEMBLY; 37 } 38 39 return {}; 40} 41 42const char *LanguageToString([[maybe_unused]] ark::panda_file::SourceLang lang) 43{ 44% Common::each_plugin_option "directive_name" do |directive_name, _, plugin_opts| 45 if (lang == <%= plugin_opts["lang_enum"] %>) { 46 return "<%= directive_name %>"; 47 } 48% end 49 50 return "PandaAssembly"; 51} 52 53const char *GetCtorName([[maybe_unused]] ark::panda_file::SourceLang lang) 54{ 55% Common::each_plugin_option "ctor_name" do |ctor_name, _, plugin_opts| 56 if (lang == <%= plugin_opts["lang_enum"] %>) { 57 return "<%= ctor_name %>"; 58 } 59% end 60 61 return ".ctor"; 62} 63 64const char *GetCctorName([[maybe_unused]] ark::panda_file::SourceLang lang) 65{ 66% Common::each_plugin_option "cctor_name" do |cctor_name, _, plugin_opts| 67 if (lang == <%= plugin_opts["lang_enum"] %>) { 68 return "<%= cctor_name %>"; 69 } 70% end 71 72 return ".cctor"; 73} 74 75const char *GetStringClassDescriptor([[maybe_unused]] ark::panda_file::SourceLang lang) 76{ 77% Common::each_plugin_option "string_class_descriptor" do |string_class_descriptor, _, plugin_opts| 78 if (lang == <%= plugin_opts["lang_enum"] %>) { 79 return "<%= string_class_descriptor %>"; 80 } 81% end 82 83 return "Lpanda/String;"; 84} 85