]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/rust/checks/errors/borrowck/rust-bir-visitor.h
48b67c0fead40ebfd25a3b84b8c3e3117001baec
[thirdparty/gcc.git] / gcc / rust / checks / errors / borrowck / rust-bir-visitor.h
1 // Copyright (C) 2020-2023 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_BIR_VISITOR_H
20 #define RUST_BIR_VISITOR_H
21
22 namespace Rust {
23 namespace BIR {
24
25 class Node;
26 class InitializerExpr;
27 template <unsigned N> class Operator;
28 class Assignment;
29 class BorrowExpr;
30 class CallExpr;
31
32 class Visitor
33 {
34 public:
35 virtual void visit (Node &node) = 0;
36 virtual void visit (InitializerExpr &expr) = 0;
37 virtual void visit (Operator<1> &expr) = 0;
38 virtual void visit (Operator<2> &expr) = 0;
39 virtual void visit (BorrowExpr &expr) = 0;
40 virtual void visit (Assignment &expr) = 0;
41 virtual void visit (CallExpr &expr) = 0;
42 };
43
44 class Visitable
45 {
46 public:
47 virtual void accept_vis (Visitor &visitor) = 0;
48 };
49
50 template <typename BASE, typename T> class VisitableImpl : public BASE
51 {
52 public:
53 void accept_vis (Visitor &visitor) override
54 {
55 visitor.visit (static_cast<T &> (*this));
56 }
57 };
58
59 } // namespace BIR
60 } // namespace Rust
61
62 #endif // RUST_BIR_VISITOR_H