Branch data Line data Source code
1 : : // Copyright (C) 2020-2024 Free Software Foundation, Inc.
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_RESOLVE_BASE_H
20 : : #define RUST_AST_RESOLVE_BASE_H
21 : :
22 : : #include "rust-ast-visitor.h"
23 : : #include "rust-ast.h"
24 : : #include "rust-name-resolver.h"
25 : : #include "rust-diagnostics.h"
26 : : #include "rust-location.h"
27 : :
28 : : namespace Rust {
29 : : namespace Resolver {
30 : :
31 : : class ResolverBase : public AST::ASTVisitor
32 : : {
33 : : public:
34 : 75428 : virtual ~ResolverBase () {}
35 : :
36 : : void visit (AST::Token &);
37 : : void visit (AST::DelimTokenTree &);
38 : : void visit (AST::AttrInputMetaItemContainer &);
39 : : void visit (AST::IdentifierExpr &);
40 : : void visit (AST::Lifetime &);
41 : : void visit (AST::LifetimeParam &);
42 : : void visit (AST::ConstGenericParam &);
43 : : void visit (AST::PathInExpression &);
44 : : void visit (AST::TypePathSegment &);
45 : : void visit (AST::TypePathSegmentGeneric &);
46 : : void visit (AST::TypePathSegmentFunction &);
47 : : void visit (AST::TypePath &);
48 : : void visit (AST::QualifiedPathInExpression &);
49 : : void visit (AST::QualifiedPathInType &);
50 : : void visit (AST::LiteralExpr &);
51 : : void visit (AST::AttrInputLiteral &);
52 : : void visit (AST::AttrInputMacro &);
53 : : void visit (AST::MetaItemLitExpr &);
54 : : void visit (AST::MetaItemPathLit &);
55 : : void visit (AST::BorrowExpr &);
56 : : void visit (AST::DereferenceExpr &);
57 : : void visit (AST::ErrorPropagationExpr &);
58 : : void visit (AST::NegationExpr &);
59 : : void visit (AST::ArithmeticOrLogicalExpr &);
60 : : void visit (AST::ComparisonExpr &);
61 : : void visit (AST::LazyBooleanExpr &);
62 : : void visit (AST::TypeCastExpr &);
63 : : void visit (AST::AssignmentExpr &);
64 : : void visit (AST::CompoundAssignmentExpr &);
65 : : void visit (AST::GroupedExpr &);
66 : : void visit (AST::ArrayElemsValues &);
67 : : void visit (AST::ArrayElemsCopied &);
68 : : void visit (AST::ArrayExpr &);
69 : : void visit (AST::ArrayIndexExpr &);
70 : : void visit (AST::TupleExpr &);
71 : : void visit (AST::TupleIndexExpr &);
72 : : void visit (AST::StructExprStruct &);
73 : : void visit (AST::StructExprFieldIdentifier &);
74 : : void visit (AST::StructExprFieldIdentifierValue &);
75 : : void visit (AST::StructExprFieldIndexValue &);
76 : : void visit (AST::StructExprStructFields &);
77 : : void visit (AST::StructExprStructBase &);
78 : : void visit (AST::CallExpr &);
79 : : void visit (AST::MethodCallExpr &);
80 : : void visit (AST::FieldAccessExpr &);
81 : : void visit (AST::ClosureExprInner &);
82 : : void visit (AST::BlockExpr &);
83 : : void visit (AST::ClosureExprInnerTyped &);
84 : : void visit (AST::ContinueExpr &);
85 : : void visit (AST::BreakExpr &);
86 : : void visit (AST::RangeFromToExpr &);
87 : : void visit (AST::RangeFromExpr &);
88 : : void visit (AST::RangeToExpr &);
89 : : void visit (AST::RangeFullExpr &);
90 : : void visit (AST::RangeFromToInclExpr &);
91 : : void visit (AST::RangeToInclExpr &);
92 : : void visit (AST::ReturnExpr &);
93 : : void visit (AST::UnsafeBlockExpr &);
94 : : void visit (AST::LoopExpr &);
95 : : void visit (AST::WhileLoopExpr &);
96 : : void visit (AST::WhileLetLoopExpr &);
97 : : void visit (AST::ForLoopExpr &);
98 : : void visit (AST::IfExpr &);
99 : : void visit (AST::IfExprConseqElse &);
100 : : void visit (AST::IfLetExpr &);
101 : : void visit (AST::IfLetExprConseqElse &);
102 : :
103 : : void visit (AST::MatchExpr &);
104 : : void visit (AST::AwaitExpr &);
105 : : void visit (AST::AsyncBlockExpr &);
106 : :
107 : : void visit (AST::TypeParam &);
108 : :
109 : : void visit (AST::LifetimeWhereClauseItem &);
110 : : void visit (AST::TypeBoundWhereClauseItem &);
111 : : void visit (AST::Module &);
112 : : void visit (AST::ExternCrate &);
113 : :
114 : : void visit (AST::UseTreeGlob &);
115 : : void visit (AST::UseTreeList &);
116 : : void visit (AST::UseTreeRebind &);
117 : : void visit (AST::UseDeclaration &);
118 : : void visit (AST::Function &);
119 : : void visit (AST::TypeAlias &);
120 : : void visit (AST::StructStruct &);
121 : : void visit (AST::TupleStruct &);
122 : : void visit (AST::EnumItem &);
123 : : void visit (AST::EnumItemTuple &);
124 : : void visit (AST::EnumItemStruct &);
125 : : void visit (AST::EnumItemDiscriminant &);
126 : : void visit (AST::Enum &);
127 : : void visit (AST::Union &);
128 : : void visit (AST::ConstantItem &);
129 : : void visit (AST::StaticItem &);
130 : : void visit (AST::TraitItemConst &);
131 : : void visit (AST::TraitItemType &);
132 : : void visit (AST::Trait &);
133 : : void visit (AST::InherentImpl &);
134 : : void visit (AST::TraitImpl &);
135 : :
136 : : void visit (AST::ExternalTypeItem &);
137 : : void visit (AST::ExternalStaticItem &);
138 : : void visit (AST::ExternBlock &);
139 : :
140 : : void visit (AST::MacroMatchFragment &);
141 : : void visit (AST::MacroMatchRepetition &);
142 : : void visit (AST::MacroMatcher &);
143 : : void visit (AST::MacroRulesDefinition &);
144 : : void visit (AST::MacroInvocation &);
145 : : void visit (AST::MetaItemPath &);
146 : : void visit (AST::MetaItemSeq &);
147 : : void visit (AST::MetaWord &);
148 : : void visit (AST::MetaNameValueStr &);
149 : : void visit (AST::MetaListPaths &);
150 : : void visit (AST::MetaListNameValueStr &);
151 : :
152 : : void visit (AST::LiteralPattern &);
153 : : void visit (AST::IdentifierPattern &);
154 : : void visit (AST::WildcardPattern &);
155 : : void visit (AST::RestPattern &);
156 : :
157 : : void visit (AST::RangePatternBoundLiteral &);
158 : : void visit (AST::RangePatternBoundPath &);
159 : : void visit (AST::RangePatternBoundQualPath &);
160 : : void visit (AST::RangePattern &);
161 : : void visit (AST::ReferencePattern &);
162 : :
163 : : void visit (AST::StructPatternFieldTuplePat &);
164 : : void visit (AST::StructPatternFieldIdentPat &);
165 : : void visit (AST::StructPatternFieldIdent &);
166 : : void visit (AST::StructPattern &);
167 : :
168 : : void visit (AST::TupleStructItemsNoRange &);
169 : : void visit (AST::TupleStructItemsRange &);
170 : : void visit (AST::TupleStructPattern &);
171 : :
172 : : void visit (AST::TuplePatternItemsMultiple &);
173 : : void visit (AST::TuplePatternItemsRanged &);
174 : : void visit (AST::TuplePattern &);
175 : : void visit (AST::GroupedPattern &);
176 : : void visit (AST::SlicePattern &);
177 : : void visit (AST::AltPattern &);
178 : :
179 : : void visit (AST::EmptyStmt &);
180 : : void visit (AST::LetStmt &);
181 : : void visit (AST::ExprStmt &);
182 : :
183 : : void visit (AST::TraitBound &);
184 : : void visit (AST::ImplTraitType &);
185 : : void visit (AST::TraitObjectType &);
186 : : void visit (AST::ParenthesisedType &);
187 : : void visit (AST::ImplTraitTypeOneBound &);
188 : : void visit (AST::TraitObjectTypeOneBound &);
189 : : void visit (AST::TupleType &);
190 : : void visit (AST::NeverType &);
191 : : void visit (AST::RawPointerType &);
192 : : void visit (AST::ReferenceType &);
193 : : void visit (AST::ArrayType &);
194 : : void visit (AST::SliceType &);
195 : : void visit (AST::InferredType &);
196 : : void visit (AST::BareFunctionType &);
197 : : void visit (AST::FunctionParam ¶m);
198 : : void visit (AST::VariadicParam ¶m);
199 : : void visit (AST::SelfParam ¶m);
200 : :
201 : : void visit (AST::FormatArgs &fmt);
202 : :
203 : : protected:
204 : 225992 : ResolverBase ()
205 : 225992 : : resolver (Resolver::get ()), mappings (Analysis::Mappings::get ()),
206 : 225992 : resolved_node (UNKNOWN_NODEID)
207 : 225992 : {}
208 : :
209 : : /**
210 : : * Resolve a visibility's path through the name resolver
211 : : */
212 : : bool resolve_visibility (const AST::Visibility &vis);
213 : :
214 : : Resolver *resolver;
215 : : Analysis::Mappings *mappings;
216 : : NodeId resolved_node;
217 : : };
218 : :
219 : : } // namespace Resolver
220 : : } // namespace Rust
221 : :
222 : : #endif // RUST_AST_RESOLVE_BASE_H
|