Debian Codegraph @

gcc/rust/hir/tree/rust-hir-bound-abstract.h

raw
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_HIR_BOUND_ABSTRACT_H
20 #define RUST_HIR_BOUND_ABSTRACT_H
21
22 #include "rust-hir-visitable.h"
23 #include "rust-system.h"
24 #include "rust-hir-map.h"
25
26 namespace Rust {
27 namespace HIR {
28
29 /* Abstract base class representing a type param bound - Lifetime and TraitBound
30 * extends it */
31 class TypeParamBound : public FullVisitable
32 {
33 public:
34 using FullVisitable::accept_vis;
35 enum BoundType
36 {
37 LIFETIME,
38 TRAITBOUND
39 };
40
41 virtual ~TypeParamBound () {}
42
43 // Unique pointer custom clone function
44 std::unique_ptr<TypeParamBound> clone_type_param_bound () const
45 {
46 return std::unique_ptr<TypeParamBound> (clone_type_param_bound_impl ());
47 }
48
49 virtual std::string as_string () const = 0;
50
51 virtual Analysis::NodeMapping get_mappings () const = 0;
52
53 virtual location_t get_locus () const = 0;
54
55 virtual BoundType get_bound_type () const = 0;
56
57 protected:
58 // Clone function implementation as pure virtual method
59 virtual TypeParamBound *clone_type_param_bound_impl () const = 0;
60 };
61
62 } // namespace HIR
63 } // namespace Rust
64
65 #endif