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_HIR_SIMPLE_PATH_H
20 : #define RUST_HIR_SIMPLE_PATH_H
21 :
22 : #include "rust-hir-map.h"
23 :
24 : namespace Rust {
25 : namespace HIR {
26 :
27 : class SimplePathSegment
28 : {
29 : Analysis::NodeMapping mappings;
30 :
31 : public:
32 70 : SimplePathSegment (Analysis::NodeMapping mappings) : mappings (mappings) {}
33 :
34 : const Analysis::NodeMapping &get_mappings () const { return mappings; }
35 : };
36 :
37 194598 : class SimplePath
38 : {
39 : std::vector<SimplePathSegment> segments;
40 : Analysis::NodeMapping mappings;
41 : location_t locus;
42 :
43 : public:
44 41491 : SimplePath (std::vector<SimplePathSegment> segments,
45 : Analysis::NodeMapping mappings, location_t locus)
46 41491 : : segments (std::move (segments)), mappings (mappings), locus (locus)
47 : {}
48 :
49 41430 : static HIR::SimplePath create_empty ()
50 : {
51 41430 : return HIR::SimplePath ({}, Analysis::NodeMapping::get_error (),
52 41430 : UNDEF_LOCATION);
53 : }
54 :
55 16733 : bool is_error () const { return segments.empty (); }
56 :
57 16 : const Analysis::NodeMapping &get_mappings () const { return mappings; }
58 16 : location_t get_locus () const { return locus; }
59 : };
60 :
61 : } // namespace HIR
62 : } // namespace Rust
63 :
64 : #endif
|