Line data Source code
1 : // Copyright (C) 2025-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 : #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 4398 : ExpressionYeast::go (AST::Crate &crate)
32 : {
33 4398 : PointerVisitor::visit (crate);
34 4398 : }
35 :
36 : void
37 225 : ExpressionYeast::dispatch_loops (std::unique_ptr<Expr> &loop_expr)
38 : {
39 225 : auto &loop = static_cast<BaseLoopExpr &> (*loop_expr.get ());
40 :
41 225 : switch (loop.get_loop_kind ())
42 : {
43 16 : case BaseLoopExpr::Kind::For:
44 16 : DesugarForLoops::go (loop_expr);
45 16 : break;
46 2 : case BaseLoopExpr::Kind::WhileLet:
47 2 : DesugarWhileLet::go (loop_expr);
48 2 : break;
49 : default:
50 : break;
51 : }
52 225 : }
53 :
54 : void
55 116274 : ExpressionYeast::reseat (std::unique_ptr<Expr> &expr)
56 : {
57 116274 : switch (expr->get_expr_kind ())
58 : {
59 1 : case Expr::Kind::ErrorPropagation:
60 1 : DesugarQuestionMark::go (expr);
61 1 : break;
62 1 : case Expr::Kind::Try:
63 1 : DesugarTryBlock::go (expr);
64 1 : break;
65 225 : case Expr::Kind::Loop:
66 225 : dispatch_loops (expr);
67 225 : break;
68 :
69 : default:
70 : break;
71 : }
72 :
73 116274 : visit (expr);
74 116274 : }
75 :
76 : } // namespace AST
77 : } // namespace Rust
|