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-name-resolver.h"
24 : : #include "rust-diagnostics.h"
25 : : #include "rust-location.h"
26 : :
27 : : namespace Rust {
28 : : namespace Resolver {
29 : :
30 : : class ResolverBase : public AST::ASTVisitor
31 : : {
32 : : public:
33 : 75652 : virtual ~ResolverBase () {}
34 : :
35 : : void visit (AST::Token &);
36 : : void visit (AST::DelimTokenTree &);
37 : : void visit (AST::AttrInputMetaItemContainer &);
38 : : void visit (AST::IdentifierExpr &);
39 : : void visit (AST::Lifetime &);
40 : : void visit (AST::LifetimeParam &);
41 : : void visit (AST::ConstGenericParam &);
42 : : void visit (AST::PathInExpression &);
43 : : void visit (AST::TypePathSegment &);
44 : : void visit (AST::TypePathSegmentGeneric &);
45 : : void visit (AST::TypePathSegmentFunction &);
46 : : void visit (AST::TypePath &);
47 : : void visit (AST::QualifiedPathInExpression &);
48 : : void visit (AST::QualifiedPathInType &);
49 : : void visit (AST::LiteralExpr &);
50 : : void visit (AST::AttrInputLiteral &);
51 : : void visit (AST::AttrInputMacro &);
52 : : void visit (AST::MetaItemLitExpr &);
53 : : void visit (AST::MetaItemPathLit &);
54 : : void visit (AST::BorrowExpr &);
55 : : void visit (AST::DereferenceExpr &);
56 : : void visit (AST::ErrorPropagationExpr &);
57 : : void visit (AST::NegationExpr &);
58 : : void visit (AST::ArithmeticOrLogicalExpr &);
59 : : void visit (AST::ComparisonExpr &);
60 : : void visit (AST::LazyBooleanExpr &);
61 : : void visit (AST::TypeCastExpr &);
62 : : void visit (AST::AssignmentExpr &);
63 : : void visit (AST::CompoundAssignmentExpr &);
64 : : void visit (AST::GroupedExpr &);
65 : : void visit (AST::ArrayElemsValues &);
66 : : void visit (AST::ArrayElemsCopied &);
67 : : void visit (AST::ArrayExpr &);
68 : : void visit (AST::ArrayIndexExpr &);
69 : : void visit (AST::TupleExpr &);
70 : : void visit (AST::TupleIndexExpr &);
71 : : void visit (AST::StructExprStruct &);
72 : : void visit (AST::StructExprFieldIdentifier &);
73 : : void visit (AST::StructExprFieldIdentifierValue &);
74 : : void visit (AST::StructExprFieldIndexValue &);
75 : : void visit (AST::StructExprStructFields &);
76 : : void visit (AST::StructExprStructBase &);
77 : : void visit (AST::CallExpr &);
78 : : void visit (AST::MethodCallExpr &);
79 : : void visit (AST::FieldAccessExpr &);
80 : : void visit (AST::ClosureExprInner &);
81 : : void visit (AST::BlockExpr &);
82 : : void visit (AST::ClosureExprInnerTyped &);
83 : : void visit (AST::ContinueExpr &);
84 : : void visit (AST::BreakExpr &);
85 : : void visit (AST::RangeFromToExpr &);
86 : : void visit (AST::RangeFromExpr &);
87 : : void visit (AST::RangeToExpr &);
88 : : void visit (AST::RangeFullExpr &);
89 : : void visit (AST::RangeFromToInclExpr &);
90 : : void visit (AST::RangeToInclExpr &);
91 : : void visit (AST::ReturnExpr &);
92 : : void visit (AST::UnsafeBlockExpr &);
93 : : void visit (AST::LoopExpr &);
94 : : void visit (AST::WhileLoopExpr &);
95 : : void visit (AST::WhileLetLoopExpr &);
96 : : void visit (AST::ForLoopExpr &);
97 : : void visit (AST::IfExpr &);
98 : : void visit (AST::IfExprConseqElse &);
99 : : void visit (AST::IfLetExpr &);
100 : : void visit (AST::IfLetExprConseqElse &);
101 : :
102 : : void visit (AST::MatchExpr &);
103 : : void visit (AST::AwaitExpr &);
104 : : void visit (AST::AsyncBlockExpr &);
105 : :
106 : : void visit (AST::TypeParam &);
107 : :
108 : : void visit (AST::LifetimeWhereClauseItem &);
109 : : void visit (AST::TypeBoundWhereClauseItem &);
110 : : void visit (AST::Module &);
111 : : void visit (AST::ExternCrate &);
112 : :
113 : : void visit (AST::UseTreeGlob &);
114 : : void visit (AST::UseTreeList &);
115 : : void visit (AST::UseTreeRebind &);
116 : : void visit (AST::UseDeclaration &);
117 : : void visit (AST::Function &);
118 : : void visit (AST::TypeAlias &);
119 : : void visit (AST::StructStruct &);
120 : : void visit (AST::TupleStruct &);
121 : : void visit (AST::EnumItem &);
122 : : void visit (AST::EnumItemTuple &);
123 : : void visit (AST::EnumItemStruct &);
124 : : void visit (AST::EnumItemDiscriminant &);
125 : : void visit (AST::Enum &);
126 : : void visit (AST::Union &);
127 : : void visit (AST::ConstantItem &);
128 : : void visit (AST::StaticItem &);
129 : : void visit (AST::TraitItemConst &);
130 : : void visit (AST::TraitItemType &);
131 : : void visit (AST::Trait &);
132 : : void visit (AST::InherentImpl &);
133 : : void visit (AST::TraitImpl &);
134 : :
135 : : void visit (AST::ExternalTypeItem &);
136 : : void visit (AST::ExternalStaticItem &);
137 : : void visit (AST::ExternalFunctionItem &);
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 : : protected:
202 : 226158 : ResolverBase ()
203 : 226158 : : resolver (Resolver::get ()), mappings (Analysis::Mappings::get ()),
204 : 226158 : resolved_node (UNKNOWN_NODEID)
205 : 226158 : {}
206 : :
207 : : /**
208 : : * Resolve a visibility's path through the name resolver
209 : : */
210 : : bool resolve_visibility (const AST::Visibility &vis);
211 : :
212 : : Resolver *resolver;
213 : : Analysis::Mappings *mappings;
214 : : NodeId resolved_node;
215 : : };
216 : :
217 : : } // namespace Resolver
218 : : } // namespace Rust
219 : :
220 : : #endif // RUST_AST_RESOLVE_BASE_H
|