blob: 6a6fd26ecd7f72f7802c18f4ea994593a4861084 [file] [log] [blame]
Vladimir Markob4eb1b12018-05-24 11:09:38 +01001/*
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 Marko5868ada2020-05-12 11:50:34 +010019#include "base/logging.h"
20
Vladimir Markob4eb1b12018-05-24 11:09:38 +010021namespace art {
22
23const char* GetClassRootDescriptor(ClassRoot class_root) {
Vladimir Marko5868ada2020-05-12 11:50:34 +010024 static const char* const class_roots_descriptors[] = {
Vladimir Markob4eb1b12018-05-24 11:09:38 +010025#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