Debian Codegraph @

gcc/rust/resolve/rust-default-resolver.h

raw
1
2 // Copyright (C) 2020-2025 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 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 &) override;
46 void visit (AST::Module &) override;
47 void visit (AST::Function &) override;
48 void visit (AST::ForLoopExpr &expr) override;
49 void visit (AST::Trait &) override;
50 void visit (AST::InherentImpl &) override;
51 void visit (AST::TraitImpl &) override;
52
53 // type dec nodes, which visit their fields or variants by default
54 void visit (AST::StructStruct &) override;
55 void visit (AST::TupleStruct &) override;
56 void visit (AST::Enum &) override;
57 void visit (AST::Union &) override;
58 void visit (AST::TypeAlias &) override;
59
60 // Visitors that visit their expression node(s)
61 void visit (AST::ClosureExprInner &) override;
62 void visit (AST::ClosureExprInnerTyped &) override;
63 void visit (AST::MatchExpr &) override;
64
65 // Leaf visitors, which do nothing by default
66 void visit (AST::ConstantItem &) override;
67 void visit (AST::StaticItem &) override;
68
69 protected:
70 DefaultResolver (NameResolutionContext &ctx) : ctx (ctx) {}
71
72 NameResolutionContext &ctx;
73 };
74
75 } // namespace Resolver2_0
76 } // namespace Rust
77
78 #endif // RUST_AST_DEFAULT_RESOLVER_H