]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/rust/resolve/rust-ast-resolve-struct-expr-field.cc
b707343d3a2bf55b0f8a8d674067ec5fd669c61f
[thirdparty/gcc.git] / gcc / rust / resolve / rust-ast-resolve-struct-expr-field.cc
1 // Copyright (C) 2020-2024 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-ast-resolve-struct-expr-field.h"
20 #include "rust-ast-resolve-expr.h"
21
22 namespace Rust {
23 namespace Resolver {
24
25 void
26 ResolveStructExprField::go (AST::StructExprField *field,
27 const CanonicalPath &prefix,
28 const CanonicalPath &canonical_prefix)
29 {
30 ResolveStructExprField resolver (prefix, canonical_prefix);
31 field->accept_vis (resolver);
32 }
33
34 ResolveStructExprField::ResolveStructExprField (
35 const CanonicalPath &prefix, const CanonicalPath &canonical_prefix)
36 : ResolverBase (), prefix (prefix), canonical_prefix (canonical_prefix)
37 {}
38
39 void
40 ResolveStructExprField::visit (AST::StructExprFieldIdentifierValue &field)
41 {
42 ResolveExpr::go (field.get_value ().get (), prefix, canonical_prefix);
43 }
44
45 void
46 ResolveStructExprField::visit (AST::StructExprFieldIndexValue &field)
47 {
48 ResolveExpr::go (field.get_value ().get (), prefix, canonical_prefix);
49 }
50
51 void
52 ResolveStructExprField::visit (AST::StructExprFieldIdentifier &field)
53 {
54 AST::IdentifierExpr expr (field.get_field_name (), {}, field.get_locus ());
55 expr.set_node_id (field.get_node_id ());
56
57 ResolveExpr::go (&expr, prefix, canonical_prefix);
58 }
59
60 } // namespace Resolver
61 } // namespace Rust