Line data Source code
1 : // Copyright (C) 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-extern-crate-loader.h"
20 : #include "rust-session-manager.h"
21 :
22 : namespace Rust {
23 11176 : ExternCrateLoaderVisitor::ExternCrateLoaderVisitor (
24 : std::vector<Session::LoadedCrate> &loaded_crate)
25 11176 : : loaded_crates (loaded_crate)
26 11176 : {}
27 :
28 : void
29 11176 : ExternCrateLoaderVisitor::go (AST::Crate &crate)
30 : {
31 11176 : visit (crate);
32 11176 : }
33 :
34 : void
35 77 : ExternCrateLoaderVisitor::visit (AST::ExternCrate &extern_crate)
36 : {
37 77 : if (extern_crate.references_self ())
38 2 : return;
39 :
40 75 : Session &session = Session::get_instance ();
41 75 : auto crate = session.load_extern_crate (extern_crate.get_referenced_crate (),
42 75 : extern_crate.get_locus ());
43 75 : if (crate)
44 24 : loaded_crates.push_back (std::move (crate.value ()));
45 75 : }
46 :
47 : } // namespace Rust
|