• 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 #ifndef PANDA_VERIFICATION_TYPE_TYPE_TYPE_INL_H_
17 #define PANDA_VERIFICATION_TYPE_TYPE_TYPE_INL_H_
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 
27 template <typename Handler>
ForAllSupertypes(Handler && handler)28 void Type::ForAllSupertypes(Handler &&handler) const
29 {
30     GetTypeSystem().ForAllSupertypesOf(*this, std::move(handler));
31 }
32 
33 template <typename Handler>
ForAllSupertypesOfSort(SortIdx sort,Handler && handler)34 void Type::ForAllSupertypesOfSort(SortIdx sort, Handler &&handler) const
35 {
36     ForAllSupertypes([this, &sort, &handler](const Type &type) {
37         if (type.Sort() == sort) {
38             return handler(type);
39         }
40         return true;
41     });
42 }
43 
44 template <typename Handler>
ForAllSubtypes(Handler && handler)45 void Type::ForAllSubtypes(Handler &&handler) const
46 {
47     GetTypeSystem().ForAllSubtypesOf(*this, std::move(handler));
48 }
49 
50 template <typename Handler>
ForAllSubtypesOfSort(SortIdx sort,Handler && handler)51 void Type::ForAllSubtypesOfSort(SortIdx sort, Handler &&handler) const
52 {
53     ForAllSubtypes([this, &sort, &handler](const Type &type) {
54         if (type.Sort() == sort) {
55             return handler(type);
56         }
57         return true;
58     });
59 }
60 }  // namespace panda::verifier
61 
62 #endif  // PANDA_VERIFICATION_TYPE_TYPE_TYPE_INL_H_
63