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_COMPILE_RESOLVE_PATH
20 : : #define RUST_COMPILE_RESOLVE_PATH
21 : :
22 : : #include "rust-compile-base.h"
23 : : #include "rust-hir-visitor.h"
24 : :
25 : : namespace Rust {
26 : : namespace Compile {
27 : :
28 : 23515 : class ResolvePathRef : public HIRCompileBase, public HIR::HIRPatternVisitor
29 : : {
30 : : public:
31 : 79 : static tree Compile (HIR::QualifiedPathInExpression &expr, Context *ctx)
32 : : {
33 : 79 : ResolvePathRef resolver (ctx);
34 : 79 : expr.accept_vis (resolver);
35 : 79 : return resolver.resolved;
36 : 79 : }
37 : :
38 : 23436 : static tree Compile (HIR::PathInExpression &expr, Context *ctx)
39 : : {
40 : 23436 : ResolvePathRef resolver (ctx);
41 : 23436 : expr.accept_vis (resolver);
42 : 23436 : return resolver.resolved;
43 : 23436 : }
44 : :
45 : : void visit (HIR::PathInExpression &expr) override;
46 : : void visit (HIR::QualifiedPathInExpression &expr) override;
47 : :
48 : : // Empty visit for unused Pattern HIR nodes.
49 : 0 : void visit (HIR::IdentifierPattern &) override {}
50 : 0 : void visit (HIR::LiteralPattern &) override {}
51 : 0 : void visit (HIR::RangePattern &) override {}
52 : 0 : void visit (HIR::ReferencePattern &) override {}
53 : 0 : void visit (HIR::SlicePattern &) override {}
54 : 0 : void visit (HIR::AltPattern &) override {}
55 : 0 : void visit (HIR::StructPattern &) override {}
56 : 0 : void visit (HIR::TuplePattern &) override {}
57 : 0 : void visit (HIR::TupleStructPattern &) override {}
58 : 0 : void visit (HIR::WildcardPattern &) override {}
59 : :
60 : 23515 : ResolvePathRef (Context *ctx)
61 : 23515 : : HIRCompileBase (ctx), resolved (error_mark_node)
62 : : {}
63 : :
64 : : tree resolve (const HIR::PathIdentSegment &final_segment,
65 : : const Analysis::NodeMapping &mappings, location_t locus,
66 : : bool is_qualified_path);
67 : :
68 : : tree resolved;
69 : : };
70 : :
71 : : } // namespace Compile
72 : : } // namespace Rust
73 : :
74 : : #endif // RUST_COMPILE_RESOLVE_PATH
|