• 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 #ifndef PANDA_TYPE_TYPE_INL_HPP__
17 #define PANDA_TYPE_TYPE_INL_HPP__
18 
19 #include "type_system.h"
20 #include "type_param.h"
21 #include "type_type.h"
22 
23 #include "verification/util/lazy.h"
24 
25 namespace panda::verifier {
26 // TODO(vdyadov): implement
27 
28 template <typename Handler>
ForAllSupertypes(Handler && handler)29 void Type::ForAllSupertypes(Handler &&handler) const
30 {
31     GetTypeSystem().ForAllSupertypesOf(*this, std::move(handler));
32 }
33 
34 template <typename Handler>
ForAllSupertypesOfSort(SortIdx sort,Handler && handler)35 void Type::ForAllSupertypesOfSort(SortIdx sort, Handler &&handler) const
36 {
37     ForAllSupertypes([this, &sort, &handler](const Type &type) {
38         if (type.Sort() == sort) {
39             return handler(type);
40         }
41         return true;
42     });
43 }
44 
45 template <typename Handler>
ForAllSubtypes(Handler && handler)46 void Type::ForAllSubtypes(Handler &&handler) const
47 {
48     GetTypeSystem().ForAllSubtypesOf(*this, std::move(handler));
49 }
50 
51 template <typename Handler>
ForAllSubtypesOfSort(SortIdx sort,Handler && handler)52 void Type::ForAllSubtypesOfSort(SortIdx sort, Handler &&handler) const
53 {
54     ForAllSubtypes([this, &sort, &handler](const Type &type) {
55         if (type.Sort() == sort) {
56             return handler(type);
57         }
58         return true;
59     });
60 }
61 }  // namespace panda::verifier
62 
63 #endif  // !PANDA_TYPE_TYPE_INL_HPP__
64