• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2021-2024 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 #ifndef PANDA_PLUGINS_ETS_RUNTIME_ETS_VTABLE_BUILDER_H_
17 #define PANDA_PLUGINS_ETS_RUNTIME_ETS_VTABLE_BUILDER_H_
18 
19 #include <cstddef>
20 #include <utility>
21 
22 #include "runtime/include/vtable_builder_variance-inl.h"
23 #include "plugins/ets/runtime/ets_vm.h"
24 
25 namespace ark::ets {
26 
27 bool ETSProtoIsOverriddenBy(Method::ProtoId const &base, Method::ProtoId const &derv);
28 
29 struct EtsVTableCompatibleSignatures {
operatorEtsVTableCompatibleSignatures30     bool operator()(const Method::ProtoId &base, const Method::ProtoId &derv) const
31     {
32         return ETSProtoIsOverriddenBy(base, derv);
33     }
34 };
35 
36 struct EtsVTableOverridePred {
operatorEtsVTableOverridePred37     bool operator()(const MethodInfo *base, const MethodInfo *derv) const
38     {
39         if (base->IsPublic() || base->IsProtected()) {
40             return true;
41         }
42 
43         if (base->IsPrivate()) {
44             return false;
45         }
46 
47         return IsInSamePackage(*base, *derv);
48     }
49 
50     bool IsInSamePackage(const MethodInfo &info1, const MethodInfo &info2) const;
51 };
52 
53 using EtsVTableBuilder = VarianceVTableBuilder<EtsVTableCompatibleSignatures, EtsVTableOverridePred>;
54 
55 }  // namespace ark::ets
56 
57 #endif  // !PANDA_PLUGINS_ETS_RUNTIME_ETS_ITABLE_BUILDER_H_
58