Branch data Line data Source code
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 : : #include "rust-expression-yeast.h"
20 : : #include "rust-ast-visitor.h"
21 : : #include "rust-desugar-question-mark.h"
22 : : #include "rust-desugar-try-block.h"
23 : : #include "rust-desugar-for-loops.h"
24 : : #include "rust-desugar-while-let.h"
25 : : #include "rust-expr.h"
26 : :
27 : : namespace Rust {
28 : : namespace AST {
29 : :
30 : : void
31 : 4354 : ExpressionYeast::go (AST::Crate &crate)
32 : : {
33 : 4354 : PointerVisitor::visit (crate);
34 : 4354 : }
35 : :
36 : : void
37 : 571 : ExpressionYeast::dispatch_loops (std::unique_ptr<Expr> &loop_expr)
38 : : {
39 : 571 : auto &loop = static_cast<BaseLoopExpr &> (*loop_expr.get ());
40 : :
41 : 571 : switch (loop.get_loop_kind ())
42 : : {
43 : 118 : case BaseLoopExpr::Kind::For:
44 : 118 : DesugarForLoops::go (loop_expr);
45 : 118 : break;
46 : 25 : case BaseLoopExpr::Kind::WhileLet:
47 : 25 : DesugarWhileLet::go (loop_expr);
48 : 25 : break;
49 : : default:
50 : : break;
51 : : }
52 : 571 : }
53 : :
54 : : void
55 : 661541 : ExpressionYeast::reseat (std::unique_ptr<Expr> &expr)
56 : : {
57 : 661541 : switch (expr->get_expr_kind ())
58 : : {
59 : 194 : case Expr::Kind::ErrorPropagation:
60 : 194 : DesugarQuestionMark::go (expr);
61 : 194 : break;
62 : 31 : case Expr::Kind::Try:
63 : 31 : DesugarTryBlock::go (expr);
64 : 31 : break;
65 : 571 : case Expr::Kind::Loop:
66 : 571 : dispatch_loops (expr);
67 : 571 : break;
68 : :
69 : : default:
70 : : break;
71 : : }
72 : :
73 : 661541 : visit (expr);
74 : 661541 : }
75 : :
76 : : } // namespace AST
77 : : } // namespace Rust
|