Line data Source code
1 : // Copyright (C) 2020-2026 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_LATE_NAME_RESOLVER_2_0_H
20 : #define RUST_LATE_NAME_RESOLVER_2_0_H
21 :
22 : #include "rust-ast-full.h"
23 : #include "rust-default-resolver.h"
24 : #include "rust-expr.h"
25 :
26 : namespace Rust {
27 : namespace Resolver2_0 {
28 :
29 5092 : class Late : public DefaultResolver
30 : {
31 : using DefaultResolver::visit;
32 :
33 : public:
34 : Late (NameResolutionContext &ctx);
35 :
36 : void go (AST::Crate &crate);
37 :
38 : void new_label (Identifier name, NodeId id);
39 :
40 : // Specialized visit bits
41 : void visit_function_params (AST::Function &function) override;
42 : void visit (AST::FunctionParam &) override;
43 :
44 : // some more label declarations
45 : void visit (AST::LetStmt &) override;
46 : void visit (AST::WhileLetLoopExpr &) override;
47 : // TODO: Do we need this?
48 : // void visit (AST::Method &) override;
49 : void visit (AST::IdentifierPattern &) override;
50 : void visit (AST::StructPatternFieldIdent &) override;
51 : void visit (AST::AltPattern &) override;
52 : void visit (AST::SelfParam &) override;
53 : void visit (AST::MatchArm &) override;
54 : void visit (AST::ForLoopExpr &) override;
55 : void visit_if_let_patterns (AST::IfLetExpr &) override;
56 :
57 : // resolutions
58 : void visit (AST::IdentifierExpr &) override;
59 : void visit (AST::StructExprFieldIdentifier &) override;
60 : void visit (AST::BreakExpr &) override;
61 : void visit (AST::ContinueExpr &) override;
62 : void visit (AST::LoopLabel &) override;
63 : void visit (AST::PathInExpression &) override;
64 : void visit_impl_type (AST::Type &) override;
65 : void visit (AST::TypePath &) override;
66 : void visit (AST::Visibility &) override;
67 : void visit (AST::Trait &) override;
68 : void visit (AST::StructExprStruct &) override;
69 : void visit (AST::StructExprStructBase &) override;
70 : void visit (AST::StructExprStructFields &) override;
71 : void visit (AST::GenericArgs &) override;
72 : void visit (AST::GenericArg &);
73 : void visit_closure_params (AST::ClosureExpr &) override;
74 : void visit (AST::ClosureExpr &) override;
75 :
76 : private:
77 : void resolve_label (AST::Lifetime &lifetime);
78 :
79 : bool funny_error;
80 :
81 : /* used to prevent "impl Self {}", "impl (Self, i32) {}", etc */
82 : bool block_big_self;
83 :
84 : bool in_bodyless_params;
85 : };
86 :
87 : // TODO: Add missing mappings and data structures
88 :
89 : } // namespace Resolver2_0
90 : } // namespace Rust
91 :
92 : #endif // ! RUST_LATE_NAME_RESOLVER_2_0_H
|