Debian Codegraph @

gcc/rust/expand/rust-derive-hash.h

raw
1 // Copyright (C) 2025 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_DERIVE_HASH_H
20 #define RUST_DERIVE_HASH_H
21
22 #include "rust-derive.h"
23
24 namespace Rust {
25 namespace AST {
26
27 class DeriveHash : DeriveVisitor
28 {
29 public:
30 DeriveHash (location_t loc);
31
32 std::unique_ptr<AST::Item> go (Item &item);
33
34 private:
35 std::unique_ptr<Item> expanded;
36
37 constexpr static const char *state = "#state";
38 constexpr static const char *state_type = "#__H";
39 constexpr static const char *discr = "#discr";
40
41 std::unique_ptr<Expr> hash_call (std::unique_ptr<Expr> &&value);
42 std::unique_ptr<AssociatedItem> hash_fn (std::unique_ptr<BlockExpr> &&block);
43 std::unique_ptr<Item>
44 hash_impl (std::unique_ptr<AssociatedItem> &&hash_fn, std::string name,
45 const std::vector<std::unique_ptr<GenericParam>> &type_generics);
46
47 MatchCase match_enum_tuple (PathInExpression variant_path,
48 const EnumItemTuple &variant);
49 MatchCase match_enum_struct (PathInExpression variant_path,
50 const EnumItemStruct &variant);
51
52 virtual void visit_struct (StructStruct &item);
53 virtual void visit_tuple (TupleStruct &item);
54 virtual void visit_enum (Enum &item);
55 virtual void visit_union (Union &item);
56 };
57
58 } // namespace AST
59 } // namespace Rust
60
61 #endif // ! RUST_DERIVE_HASH_H