Branch data Line data Source code
1 : :
2 : : // Copyright (C) 2020-2024 Free Software Foundation, Inc.
3 : :
4 : : // This file is part of GCC.
5 : :
6 : : // GCC is free software; you can redistribute it and/or modify it under
7 : : // the terms of the GNU General Public License as published by the Free
8 : : // Software Foundation; either version 3, or (at your option) any later
9 : : // version.
10 : :
11 : : // GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 : : // WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 : : // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 : : // for more details.
15 : :
16 : : // You should have received a copy of the GNU General Public License
17 : : // along with GCC; see the file COPYING3. If not see
18 : : // <http://www.gnu.org/licenses/>.
19 : :
20 : : #ifndef RUST_AST_DEFAULT_RESOLVER_H
21 : : #define RUST_AST_DEFAULT_RESOLVER_H
22 : :
23 : : #include "rust-ast-visitor.h"
24 : : #include "rust-name-resolution-context.h"
25 : :
26 : : namespace Rust {
27 : : namespace Resolver2_0 {
28 : :
29 : : /**
30 : : * The `DefaultResolver` is a base visitor for all passes of our name resolution
31 : : * algorithm: `TopLevel`, `Easy` and `Late`. It does not do a lot, apart from
32 : : * visiting each node's subnodes - a block's statements, a function call's
33 : : * arguments...
34 : : */
35 : : class DefaultResolver : public AST::DefaultASTVisitor
36 : : {
37 : : public:
38 : : using AST::DefaultASTVisitor::visit;
39 : :
40 : 27 : virtual ~DefaultResolver () {}
41 : :
42 : : // First, our lexical scope expressions - these visit their sub nodes, always
43 : : // these nodes create new scopes and ribs - they are often used to declare new
44 : : // variables, such as a for loop's iterator, or a function's arguments
45 : : void visit (AST::BlockExpr &);
46 : : void visit (AST::Module &);
47 : : void visit (AST::Function &);
48 : : void visit (AST::ForLoopExpr &);
49 : : void visit (AST::Trait &);
50 : : void visit (AST::InherentImpl &);
51 : : void visit (AST::TraitImpl &);
52 : :
53 : : // type dec nodes, which visit their fields or variants by default
54 : : void visit (AST::StructStruct &);
55 : : void visit (AST::Enum &);
56 : :
57 : : // Visitors that visit their expression node(s)
58 : : void visit (AST::StructExprFieldIdentifierValue &);
59 : : void visit (AST::StructExprFieldIndexValue &);
60 : : void visit (AST::ClosureExprInner &);
61 : : void visit (AST::ClosureExprInnerTyped &);
62 : : void visit (AST::ContinueExpr &);
63 : : void visit (AST::RangeFromToExpr &);
64 : : void visit (AST::RangeFromExpr &);
65 : : void visit (AST::RangeToExpr &);
66 : : void visit (AST::RangeFromToInclExpr &);
67 : : void visit (AST::RangeToInclExpr &);
68 : : void visit (AST::ReturnExpr &);
69 : : void visit (AST::LoopExpr &);
70 : : void visit (AST::WhileLoopExpr &);
71 : : void visit (AST::WhileLetLoopExpr &);
72 : : void visit (AST::IfExpr &);
73 : : void visit (AST::IfExprConseqElse &);
74 : : void visit (AST::IfLetExpr &);
75 : : void visit (AST::IfLetExprConseqElse &);
76 : : void visit (AST::MatchExpr &);
77 : : void visit (AST::AwaitExpr &);
78 : : void visit (AST::AsyncBlockExpr &);
79 : :
80 : : // Leaf visitors, which do nothing by default
81 : : void visit (AST::DelimTokenTree &);
82 : : void visit (AST::AttrInputMetaItemContainer &);
83 : : void visit (AST::IdentifierExpr &);
84 : : void visit (AST::LifetimeParam &);
85 : : void visit (AST::ConstGenericParam &);
86 : : void visit (AST::PathInExpression &);
87 : : void visit (AST::TypePathSegmentGeneric &);
88 : : void visit (AST::TypePathSegmentFunction &);
89 : : void visit (AST::TypePath &);
90 : : void visit (AST::QualifiedPathInExpression &);
91 : : void visit (AST::QualifiedPathInType &);
92 : : void visit (AST::LiteralExpr &);
93 : : void visit (AST::AttrInputLiteral &);
94 : : void visit (AST::AttrInputMacro &);
95 : : void visit (AST::MetaItemLitExpr &);
96 : : void visit (AST::MetaItemPathLit &);
97 : : void visit (AST::StructExprStruct &);
98 : : void visit (AST::StructExprStructFields &);
99 : : void visit (AST::StructExprStructBase &);
100 : : void visit (AST::TypeParam &);
101 : : void visit (AST::LifetimeWhereClauseItem &);
102 : : void visit (AST::TypeBoundWhereClauseItem &);
103 : : void visit (AST::ExternCrate &);
104 : : void visit (AST::UseTreeGlob &);
105 : : void visit (AST::UseTreeList &);
106 : : void visit (AST::UseTreeRebind &);
107 : : void visit (AST::UseDeclaration &);
108 : : void visit (AST::TypeAlias &);
109 : : void visit (AST::EnumItem &);
110 : : void visit (AST::EnumItemTuple &);
111 : : void visit (AST::EnumItemStruct &);
112 : : void visit (AST::EnumItemDiscriminant &);
113 : : void visit (AST::ConstantItem &);
114 : : void visit (AST::StaticItem &);
115 : : void visit (AST::TraitItemConst &);
116 : : void visit (AST::TraitItemType &);
117 : : void visit (AST::ExternalTypeItem &);
118 : : void visit (AST::ExternalStaticItem &);
119 : : void visit (AST::MacroMatchRepetition &);
120 : : void visit (AST::MacroMatcher &);
121 : : void visit (AST::MacroRulesDefinition &);
122 : : void visit (AST::MacroInvocation &);
123 : : void visit (AST::MetaItemPath &);
124 : : void visit (AST::MetaItemSeq &);
125 : : void visit (AST::MetaListPaths &);
126 : : void visit (AST::MetaListNameValueStr &);
127 : : void visit (AST::RangePatternBoundPath &);
128 : : void visit (AST::RangePatternBoundQualPath &);
129 : : void visit (AST::RangePattern &);
130 : : void visit (AST::ReferencePattern &);
131 : : void visit (AST::StructPatternFieldTuplePat &);
132 : : void visit (AST::StructPatternFieldIdentPat &);
133 : : void visit (AST::StructPatternFieldIdent &);
134 : : void visit (AST::StructPattern &);
135 : : void visit (AST::TupleStructItemsNoRange &);
136 : : void visit (AST::TupleStructItemsRange &);
137 : : void visit (AST::TupleStructPattern &);
138 : : void visit (AST::TuplePatternItemsMultiple &);
139 : : void visit (AST::TuplePatternItemsRanged &);
140 : : void visit (AST::TuplePattern &);
141 : : void visit (AST::GroupedPattern &);
142 : : void visit (AST::SlicePattern &);
143 : : void visit (AST::AltPattern &);
144 : : void visit (AST::EmptyStmt &);
145 : : void visit (AST::TraitBound &);
146 : : void visit (AST::ImplTraitType &);
147 : : void visit (AST::TraitObjectType &);
148 : : void visit (AST::ParenthesisedType &);
149 : : void visit (AST::ImplTraitTypeOneBound &);
150 : : void visit (AST::TraitObjectTypeOneBound &);
151 : : void visit (AST::TupleType &);
152 : : void visit (AST::ReferenceType &);
153 : : void visit (AST::ArrayType &);
154 : : void visit (AST::SliceType &);
155 : : void visit (AST::BareFunctionType &);
156 : : void visit (AST::FunctionParam &);
157 : : void visit (AST::VariadicParam &);
158 : : void visit (AST::SelfParam &);
159 : :
160 : : protected:
161 : 97 : DefaultResolver (NameResolutionContext &ctx) : ctx (ctx) {}
162 : :
163 : : NameResolutionContext &ctx;
164 : : };
165 : :
166 : : } // namespace Resolver2_0
167 : : } // namespace Rust
168 : :
169 : : #endif // RUST_AST_DEFAULT_RESOLVER_H
|