]>
Commit | Line | Data |
---|---|---|
a945c346 | 1 | // Copyright (C) 2020-2024 Free Software Foundation, Inc. |
7999cf32 PH |
2 | |
3 | // This file is part of GCC. | |
4 | ||
5 | // GCC is free software; you can redistribute it and/or modify it under | |
6 | // the terms of the GNU General Public License as published by the Free | |
7 | // Software Foundation; either version 3, or (at your option) any later | |
8 | // version. | |
9 | ||
10 | // GCC is distributed in the hope that it will be useful, but WITHOUT ANY | |
11 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
12 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
13 | // for more details. | |
14 | ||
15 | // You should have received a copy of the GNU General Public License | |
16 | // along with GCC; see the file COPYING3. If not see | |
17 | // <http://www.gnu.org/licenses/>. | |
18 | ||
19 | #ifndef RUST_AST_LOWER_TYPE | |
20 | #define RUST_AST_LOWER_TYPE | |
21 | ||
22 | #include "rust-ast-lower-base.h" | |
7999cf32 PH |
23 | #include "rust-ast-lower-expr.h" |
24 | ||
25 | namespace Rust { | |
26 | namespace HIR { | |
27 | ||
28 | class ASTLowerTypePath : public ASTLoweringBase | |
29 | { | |
30 | protected: | |
31 | using Rust::HIR::ASTLoweringBase::visit; | |
32 | ||
33 | public: | |
875f722d | 34 | static HIR::TypePath *translate (AST::TypePath &type); |
7999cf32 | 35 | |
875f722d PH |
36 | void visit (AST::TypePathSegmentFunction &segment) override; |
37 | void visit (AST::TypePathSegment &segment) override; | |
7999cf32 | 38 | void visit (AST::TypePathSegmentGeneric &segment) override; |
875f722d | 39 | void visit (AST::TypePath &path) override; |
7999cf32 PH |
40 | |
41 | protected: | |
42 | HIR::TypePathSegment *translated_segment; | |
43 | ||
44 | private: | |
45 | HIR::TypePath *translated; | |
46 | }; | |
47 | ||
48 | class ASTLowerQualifiedPathInType : public ASTLowerTypePath | |
49 | { | |
50 | using ASTLowerTypePath::visit; | |
51 | ||
52 | public: | |
875f722d | 53 | static HIR::QualifiedPathInType *translate (AST::QualifiedPathInType &type); |
7999cf32 PH |
54 | |
55 | void visit (AST::QualifiedPathInType &path) override; | |
56 | ||
57 | private: | |
58 | HIR::QualifiedPathInType *translated; | |
59 | }; | |
60 | ||
61 | class ASTLoweringType : public ASTLoweringBase | |
62 | { | |
63 | using Rust::HIR::ASTLoweringBase::visit; | |
64 | ||
65 | public: | |
e01c9f40 | 66 | static HIR::Type *translate (AST::Type &type, |
bc1a47f7 | 67 | bool default_to_static_lifetime = false); |
7999cf32 | 68 | |
8220e7b7 AC |
69 | void visit (AST::BareFunctionType &fntype) override; |
70 | void visit (AST::TupleType &tuple) override; | |
71 | void visit (AST::TypePath &path) override; | |
72 | void visit (AST::QualifiedPathInType &path) override; | |
73 | void visit (AST::ArrayType &type) override; | |
74 | void visit (AST::ReferenceType &type) override; | |
75 | void visit (AST::RawPointerType &type) override; | |
76 | void visit (AST::SliceType &type) override; | |
77 | void visit (AST::InferredType &type) override; | |
78 | void visit (AST::NeverType &type) override; | |
7999cf32 | 79 | void visit (AST::TraitObjectTypeOneBound &type) override; |
7999cf32 PH |
80 | void visit (AST::TraitObjectType &type) override; |
81 | ||
82 | private: | |
bc1a47f7 JD |
83 | ASTLoweringType (bool default_to_static_lifetime) |
84 | : ASTLoweringBase (), | |
85 | default_to_static_lifetime (default_to_static_lifetime), | |
86 | translated (nullptr) | |
87 | {} | |
88 | ||
89 | /** Used when compiling const and static items. */ | |
90 | bool default_to_static_lifetime; | |
7999cf32 PH |
91 | |
92 | HIR::Type *translated; | |
93 | }; | |
94 | ||
95 | class ASTLowerGenericParam : public ASTLoweringBase | |
96 | { | |
97 | using Rust::HIR::ASTLoweringBase::visit; | |
98 | ||
99 | public: | |
e01c9f40 | 100 | static HIR::GenericParam *translate (AST::GenericParam ¶m); |
8220e7b7 AC |
101 | |
102 | void visit (AST::LifetimeParam ¶m) override; | |
103 | void visit (AST::ConstGenericParam ¶m) override; | |
104 | void visit (AST::TypeParam ¶m) override; | |
7999cf32 PH |
105 | |
106 | private: | |
107 | ASTLowerGenericParam () : ASTLoweringBase (), translated (nullptr) {} | |
108 | ||
109 | HIR::GenericParam *translated; | |
110 | }; | |
111 | ||
112 | class ASTLoweringTypeBounds : public ASTLoweringBase | |
113 | { | |
114 | using Rust::HIR::ASTLoweringBase::visit; | |
115 | ||
116 | public: | |
e01c9f40 | 117 | static HIR::TypeParamBound *translate (AST::TypeParamBound &type); |
8220e7b7 AC |
118 | |
119 | void visit (AST::TraitBound &bound) override; | |
120 | void visit (AST::Lifetime &bound) override; | |
7999cf32 PH |
121 | |
122 | private: | |
123 | ASTLoweringTypeBounds () : ASTLoweringBase (), translated (nullptr) {} | |
124 | ||
125 | HIR::TypeParamBound *translated; | |
126 | }; | |
127 | ||
128 | class ASTLowerWhereClauseItem : public ASTLoweringBase | |
129 | { | |
130 | using Rust::HIR::ASTLoweringBase::visit; | |
131 | ||
132 | public: | |
8220e7b7 AC |
133 | static HIR::WhereClauseItem *translate (AST::WhereClauseItem &item); |
134 | ||
135 | void visit (AST::LifetimeWhereClauseItem &item) override; | |
136 | void visit (AST::TypeBoundWhereClauseItem &item) override; | |
7999cf32 PH |
137 | |
138 | private: | |
139 | ASTLowerWhereClauseItem () : ASTLoweringBase (), translated (nullptr) {} | |
140 | ||
141 | HIR::WhereClauseItem *translated; | |
142 | }; | |
143 | ||
144 | } // namespace HIR | |
145 | } // namespace Rust | |
146 | ||
147 | #endif // RUST_AST_LOWER_TYPE |