• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2021-2022 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 "default_plugin.h"
17 #include "abs_int_inl_compat_checks.h"
18 #include "source_lang_enum.h"
19 #include "verifier_messages.h"
20 #include "runtime/include/mtmanaged_thread.h"
21 #include "runtime/include/runtime.h"
22 
23 namespace panda::verifier::plugin {
24 
CreateManagedThread() const25 ManagedThread *DefaultPlugin::CreateManagedThread() const
26 {
27     return MTManagedThread::Create(Runtime::GetCurrent(), Runtime::GetCurrent()->GetPandaVM());
28 }
29 
DestroyManagedThread(ManagedThread * thr) const30 void DefaultPlugin::DestroyManagedThread(ManagedThread *thr) const
31 {
32     MTManagedThread::CastFromThread(thr)->Destroy();
33 }
34 
TypeSystemSetup(TypeSystem * types) const35 void DefaultPlugin::TypeSystemSetup(TypeSystem *types) const
36 {
37     types->SetSupertypeOfArray(types->Object());
38 }
39 
NormalizeType(Type type,TypeSystem * types) const40 Type DefaultPlugin::NormalizeType(Type type, TypeSystem *types) const
41 {
42     auto integral32 = Type {Type::Builtin::INTEGRAL32};
43     auto integral64 = Type {Type::Builtin::INTEGRAL64};
44     auto float32 = Type {Type::Builtin::FLOAT32};
45     auto float64 = Type {Type::Builtin::FLOAT64};
46     Type result;
47     if (IsSubtype(type, integral32, types)) {
48         result = integral32;
49     } else if (IsSubtype(type, integral64, types)) {
50         result = integral64;
51     } else if (IsSubtype(type, float32, types)) {
52         result = float32;
53     } else if (IsSubtype(type, float64, types)) {
54         result = float64;
55     } else {
56         result = type;
57     }
58     return result;
59 }
60 
61 }  // namespace panda::verifier::plugin
62