Branch data Line data Source code
1 : : // Copyright (C) 2020-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_AST_LOWER_STRUCT_FIELD_EXPR
20 : : #define RUST_AST_LOWER_STRUCT_FIELD_EXPR
21 : :
22 : : #include "rust-diagnostics.h"
23 : : #include "rust-ast-lower-base.h"
24 : :
25 : : namespace Rust {
26 : : namespace HIR {
27 : :
28 : : class ASTLowerStructExprField : public ASTLoweringBase
29 : : {
30 : : using Rust::HIR::ASTLoweringBase::visit;
31 : :
32 : : public:
33 : 1536 : static HIR::StructExprField *translate (AST::StructExprField &field)
34 : : {
35 : 3072 : ASTLowerStructExprField compiler;
36 : 1536 : field.accept_vis (compiler);
37 : 1536 : rust_assert (compiler.translated != nullptr);
38 : :
39 : 1536 : compiler.mappings->insert_hir_struct_field (compiler.translated);
40 : 1536 : compiler.mappings->insert_location (
41 : 1536 : compiler.translated->get_mappings ().get_hirid (), field.get_locus ());
42 : :
43 : 1536 : return compiler.translated;
44 : 1536 : }
45 : :
46 : 1536 : ~ASTLowerStructExprField () {}
47 : :
48 : : void visit (AST::StructExprFieldIdentifierValue &field) override;
49 : :
50 : : void visit (AST::StructExprFieldIndexValue &field) override;
51 : :
52 : : void visit (AST::StructExprFieldIdentifier &field) override;
53 : :
54 : : private:
55 : 1536 : ASTLowerStructExprField () : translated (nullptr) {}
56 : :
57 : : HIR::StructExprField *translated;
58 : : };
59 : :
60 : : } // namespace HIR
61 : : } // namespace Rust
62 : :
63 : : #endif // RUST_AST_LOWER_STRUCT_FIELD_EXPR
|