diff options
author | John Hodge <tpg@mutabah.net> | 2016-10-24 11:16:35 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-10-24 11:16:35 +0800 |
commit | 85b8adcc8d9f65e175437699ed3d36362c7ac2b7 (patch) | |
tree | 3a941207c849134e0e620b9576c0cac2a876fa03 | |
parent | be1a8b9e0464551a61d9f216c67b0542b33559b0 (diff) | |
download | mrust-85b8adcc8d9f65e175437699ed3d36362c7ac2b7.tar.gz |
Expand - Implement module_path! macro
-rw-r--r-- | src/expand/file_line.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/expand/file_line.cpp b/src/expand/file_line.cpp index 28bd73b7..8ce56436 100644 --- a/src/expand/file_line.cpp +++ b/src/expand/file_line.cpp @@ -21,6 +21,22 @@ class CExpanderLine: } }; +class CExpanderModulePath: + public ExpandProcMacro +{ + ::std::unique_ptr<TokenStream> expand(const Span& sp, const AST::Crate& crate, const ::std::string& ident, const TokenTree& tt, AST::Module& mod) override + { + ::std::string path_str; + for(const auto& comp : mod.path().nodes()) { + if( &comp != &mod.path().nodes().front() ) + path_str += "::"; + path_str += comp.name(); + } + return box$( TTStreamO(TokenTree( Token(TOK_STRING, mv$(path_str)) )) ); + } +}; + STATIC_MACRO("file", CExpanderFile); STATIC_MACRO("line", CExpanderLine); +STATIC_MACRO("module_path", CExpanderModulePath); |