diff options
author | John Hodge <tpg@mutabah.net> | 2016-09-25 23:09:17 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-09-25 23:09:17 +0800 |
commit | 6c16703e6a3be274c4fe183ffde10fd7a20f8236 (patch) | |
tree | 8a9b0ad911f73b9e2f6357fa6534e4583165dd40 /src/dump_as_rust.cpp | |
parent | 72e2a322f52edd7bf3f37ad840f2d48be4192d62 (diff) | |
download | mrust-6c16703e6a3be274c4fe183ffde10fd7a20f8236.tar.gz |
AST - Convert use statements to normal items
Diffstat (limited to 'src/dump_as_rust.cpp')
-rw-r--r-- | src/dump_as_rust.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/dump_as_rust.cpp b/src/dump_as_rust.cpp index 0a322ee5..8909e2e4 100644 --- a/src/dump_as_rust.cpp +++ b/src/dump_as_rust.cpp @@ -558,21 +558,23 @@ void RustPrinter::handle_module(const AST::Module& mod) { bool need_nl = true; - for( const auto& i : mod.imports() ) + for( const auto& i : mod.items() ) { + if( !i.data.is_Use() ) continue ; + const auto& i_data = i.data.as_Use(); //if(need_nl) { // m_os << "\n"; // need_nl = false; //} - if( i.data.path == AST::Path() ) { + if( i_data.path == AST::Path() ) { continue ; } - m_os << indent() << (i.is_pub ? "pub " : "") << "use " << i.data; + m_os << indent() << (i.is_pub ? "pub " : "") << "use " << i_data; if( i.name == "" ) { m_os << "::*"; } - else if( i.data.path.nodes().back().name() != i.name ) + else if( i_data.path.nodes().back().name() != i.name ) { m_os << " as " << i.name; } |