Vladimir Marko | b4eb1b1 | 2018-05-24 11:09:38 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include "class_root.h" |
| 18 | |
Vladimir Marko | 5868ada | 2020-05-12 11:50:34 +0100 | [diff] [blame] | 19 | #include "base/logging.h" |
| 20 | |
Vladimir Marko | b4eb1b1 | 2018-05-24 11:09:38 +0100 | [diff] [blame] | 21 | namespace art { |
| 22 | |
| 23 | const char* GetClassRootDescriptor(ClassRoot class_root) { |
Vladimir Marko | 5868ada | 2020-05-12 11:50:34 +0100 | [diff] [blame] | 24 | static const char* const class_roots_descriptors[] = { |
Vladimir Marko | b4eb1b1 | 2018-05-24 11:09:38 +0100 | [diff] [blame] | 25 | #define CLASS_ROOT_DESCRIPTOR(name, descriptor, mirror_type) descriptor, |
| 26 | CLASS_ROOT_LIST(CLASS_ROOT_DESCRIPTOR) |
| 27 | #undef CLASS_ROOT_DESCRIPTOR |
| 28 | }; |
| 29 | static_assert(arraysize(class_roots_descriptors) == static_cast<size_t>(ClassRoot::kMax), |
| 30 | "Mismatch between class descriptors and class-root enum"); |
| 31 | |
| 32 | DCHECK_LT(static_cast<uint32_t>(class_root), static_cast<uint32_t>(ClassRoot::kMax)); |
| 33 | const char* descriptor = class_roots_descriptors[static_cast<size_t>(class_root)]; |
| 34 | CHECK(descriptor != nullptr); |
| 35 | return descriptor; |
| 36 | } |
| 37 | |
| 38 | } // namespace art |