1 /* 2 * Copyright (c) 2021 - 2025 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 "boxingConverter.h" 17 #include "checker/types/ets/types.h" 18 #include "checker/ETSchecker.h" 19 #include "util/helpers.h" 20 #include "checker/types/globalTypesHolder.h" 21 22 namespace ark::es2panda::checker { 23 Convert(ETSChecker const * checker,Type const * source)24checker::ETSObjectType *BoxingConverter::Convert(ETSChecker const *checker, Type const *source) 25 { 26 auto typeHolder = checker->GetGlobalTypesHolder(); 27 28 switch (checker::ETSChecker::TypeKind(source)) { 29 case checker::TypeFlag::ETS_BOOLEAN: 30 return typeHolder->GlobalETSBooleanBuiltinType()->AsETSObjectType(); 31 case checker::TypeFlag::BYTE: 32 return typeHolder->GlobalByteBuiltinType()->AsETSObjectType(); 33 case checker::TypeFlag::SHORT: 34 return typeHolder->GlobalShortBuiltinType()->AsETSObjectType(); 35 case checker::TypeFlag::CHAR: 36 return typeHolder->GlobalCharBuiltinType()->AsETSObjectType(); 37 case checker::TypeFlag::INT: 38 return typeHolder->GlobalIntegerBuiltinType()->AsETSObjectType(); 39 case checker::TypeFlag::LONG: 40 return typeHolder->GlobalLongBuiltinType()->AsETSObjectType(); 41 case checker::TypeFlag::FLOAT: 42 return typeHolder->GlobalFloatBuiltinType()->AsETSObjectType(); 43 case checker::TypeFlag::DOUBLE: 44 return typeHolder->GlobalDoubleBuiltinType()->AsETSObjectType(); 45 default: 46 ES2PANDA_UNREACHABLE(); 47 } 48 } 49 50 } // namespace ark::es2panda::checker 51