• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 "runtime/include/tooling/pt_class.h"
17 
18 #include <limits>
19 
20 #include "runtime/include/runtime.h"
21 #include "libpandabase/utils/utf.h"
22 #include "pt_class_private.h"
23 #include "pt_lang_ext_private.h"
24 
25 namespace panda::tooling {
26 static auto *g_invalidRef = reinterpret_cast<PtReference *>(std::numeric_limits<uintptr_t>::max());
27 
28 // NOLINTNEXTLINE(fuchsia-statically-constructed-objects)
29 static const PtClass DYNAMIC_CLASS = PtClass(g_invalidRef);
30 
GetDynamicClass()31 PtClass GetDynamicClass()
32 {
33     return DYNAMIC_CLASS;
34 }
35 
GetDescriptor() const36 const char *PtClass::GetDescriptor() const
37 {
38     if (GetReference() == DYNAMIC_CLASS.GetReference()) {
39         return nullptr;
40     }
41 
42     auto *ext = static_cast<PtLangExtPrivate *>(Runtime::GetCurrent()->GetPtLangExt());
43     Class *runtimeClass = ext->PtClassToClass(*this);
44     return utf::Mutf8AsCString(runtimeClass->GetDescriptor());
45 }
46 }  // namespace panda::tooling
47