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