1 /** 2 * Copyright (c) 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 #include "plugins/ets/runtime/ets_class_root.h" 17 18 namespace ark::ets { 19 20 // CC-OFFNXT(huge_cyclomatic_complexity) big switch case ToEtsClassRoot(ClassRoot classRoot)21EtsClassRoot ToEtsClassRoot(ClassRoot classRoot) 22 { 23 switch (classRoot) { 24 // Primitives types 25 case ClassRoot::V: 26 return EtsClassRoot::VOID; 27 case ClassRoot::U1: 28 return EtsClassRoot::BOOLEAN; 29 case ClassRoot::I8: 30 return EtsClassRoot::BYTE; 31 case ClassRoot::U16: 32 return EtsClassRoot::CHAR; 33 case ClassRoot::I16: 34 return EtsClassRoot::SHORT; 35 case ClassRoot::I32: 36 return EtsClassRoot::INT; 37 case ClassRoot::I64: 38 return EtsClassRoot::LONG; 39 case ClassRoot::F32: 40 return EtsClassRoot::FLOAT; 41 case ClassRoot::F64: 42 return EtsClassRoot::DOUBLE; 43 44 // Primitive arrays types 45 case ClassRoot::ARRAY_U1: 46 return EtsClassRoot::BOOLEAN_ARRAY; 47 case ClassRoot::ARRAY_U8: 48 return EtsClassRoot::BYTE_ARRAY; 49 case ClassRoot::ARRAY_U16: 50 return EtsClassRoot::CHAR_ARRAY; 51 case ClassRoot::ARRAY_I16: 52 return EtsClassRoot::SHORT_ARRAY; 53 case ClassRoot::ARRAY_I32: 54 return EtsClassRoot::INT_ARRAY; 55 case ClassRoot::ARRAY_I64: 56 return EtsClassRoot::LONG_ARRAY; 57 case ClassRoot::ARRAY_F32: 58 return EtsClassRoot::FLOAT_ARRAY; 59 case ClassRoot::ARRAY_F64: 60 return EtsClassRoot::DOUBLE_ARRAY; 61 62 // Object types 63 case ClassRoot::CLASS: 64 return EtsClassRoot::CLASS; 65 case ClassRoot::OBJECT: 66 return EtsClassRoot::OBJECT; 67 68 // Other types 69 case ClassRoot::STRING: 70 return EtsClassRoot::STRING; 71 case ClassRoot::ARRAY_CLASS: 72 return EtsClassRoot::STRING_ARRAY; 73 default: 74 LOG(FATAL, ETS) << "Unsupporeted class_root: " << helpers::ToUnderlying(classRoot); 75 } 76 77 UNREACHABLE(); 78 } 79 80 } // namespace ark::ets 81