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#ifndef PANDA_ASSEMBLER_EXTENSIONS_REGISTER_EXTENSIONS_H 17#define PANDA_ASSEMBLER_EXTENSIONS_REGISTER_EXTENSIONS_H 18 19#include "extensions/extensions.h" 20#include "extensions/ecmascript_meta.h" 21 22namespace panda::pandasm::extensions { 23std::unique_ptr<panda::pandasm::RecordMetadata> MetadataExtension::CreateRecordMetadata(panda::panda_file::SourceLang lang) 24{ 25 switch (lang) { 26 case Language::ECMASCRIPT: 27 return std::make_unique<panda::pandasm::extensions::ecmascript::RecordMetadata>(); 28 case Language::PANDA_ASSEMBLY: 29 return std::make_unique<panda::pandasm::RecordMetadata>(); 30 default: 31 break; 32 } 33 34 UNREACHABLE(); 35 return {}; 36} 37 38std::unique_ptr<panda::pandasm::FieldMetadata> MetadataExtension::CreateFieldMetadata(panda::panda_file::SourceLang lang) 39{ 40 switch (lang) { 41 case Language::ECMASCRIPT: 42 return std::make_unique<panda::pandasm::FieldMetadata>(); 43 case Language::PANDA_ASSEMBLY: 44 return std::make_unique<panda::pandasm::FieldMetadata>(); 45 default: 46 break; 47 } 48 49 UNREACHABLE(); 50 return {}; 51} 52 53std::unique_ptr<panda::pandasm::FunctionMetadata> MetadataExtension::CreateFunctionMetadata(panda::panda_file::SourceLang lang) 54{ 55 switch (lang) { 56 case Language::ECMASCRIPT: 57 return std::make_unique<panda::pandasm::FunctionMetadata>(); 58 case Language::PANDA_ASSEMBLY: 59 return std::make_unique<panda::pandasm::FunctionMetadata>(); 60 default: 61 break; 62 } 63 64 UNREACHABLE(); 65 return {}; 66} 67 68std::unique_ptr<panda::pandasm::ParamMetadata> MetadataExtension::CreateParamMetadata(panda::panda_file::SourceLang lang) 69{ 70 switch (lang) { 71 case Language::ECMASCRIPT: 72 return std::make_unique<panda::pandasm::ParamMetadata>(); 73 case Language::PANDA_ASSEMBLY: 74 return std::make_unique<panda::pandasm::ParamMetadata>(); 75 default: 76 break; 77 } 78 79 UNREACHABLE(); 80 return {}; 81} 82} // namespace panda::pandasm::extensions 83#endif // PANDA_ASSEMBLER_EXTENSIONS_REGISTER_EXTENSIONS_H 84