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 19 namespace art { 20 GetClassRootDescriptor(ClassRoot class_root)21const char* GetClassRootDescriptor(ClassRoot class_root) { 22 static const char* class_roots_descriptors[] = { 23 #define CLASS_ROOT_DESCRIPTOR(name, descriptor, mirror_type) descriptor, 24 CLASS_ROOT_LIST(CLASS_ROOT_DESCRIPTOR) 25 #undef CLASS_ROOT_DESCRIPTOR 26 }; 27 static_assert(arraysize(class_roots_descriptors) == static_cast<size_t>(ClassRoot::kMax), 28 "Mismatch between class descriptors and class-root enum"); 29 30 DCHECK_LT(static_cast<uint32_t>(class_root), static_cast<uint32_t>(ClassRoot::kMax)); 31 const char* descriptor = class_roots_descriptors[static_cast<size_t>(class_root)]; 32 CHECK(descriptor != nullptr); 33 return descriptor; 34 } 35 36 } // namespace art 37