diff options
author | Ben Boeckel <mathstuf@gmail.com> | 2021-10-31 19:59:37 -0400 |
---|---|---|
committer | Ben Boeckel <mathstuf@gmail.com> | 2021-11-03 07:09:01 -0400 |
commit | 1657ee53d578d68c7d807312b1063ffd804d7ef9 (patch) | |
tree | 502c1c87dc290c7301907a46791c4b2996697cbb /gcc/rust/parse/rust-parse.h | |
parent | 09af9b16b436606fa8ced0aa6cc111555bdc3da7 (diff) | |
download | gcc-1657ee53d578d68c7d807312b1063ffd804d7ef9.zip gcc-1657ee53d578d68c7d807312b1063ffd804d7ef9.tar.gz gcc-1657ee53d578d68c7d807312b1063ffd804d7ef9.tar.bz2 |
rust: track inline module scopes for module file resolution
The set of inline modules is required to find the expected location of a
module file. Track this information with an RAII object
(`InlineModuleStackScope`) and pass it down to any out-of-line modules
so that, when requested, the set of inline modules can be added to the
search path.
Signed-off-by: Ben Boeckel <mathstuf@gmail.com>
Diffstat (limited to 'gcc/rust/parse/rust-parse.h')
-rw-r--r-- | gcc/rust/parse/rust-parse.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/gcc/rust/parse/rust-parse.h b/gcc/rust/parse/rust-parse.h index 45f00f5..acab7ff 100644 --- a/gcc/rust/parse/rust-parse.h +++ b/gcc/rust/parse/rust-parse.h @@ -622,7 +622,26 @@ private: ManagedTokenSource lexer; // The error list. std::vector<Error> error_table; + // The names of inline modules while parsing. + std::vector<std::string> inline_module_stack; + + class InlineModuleStackScope + { + private: + Parser &parser; + + public: + InlineModuleStackScope (Parser &parser, std::string name) : parser (parser) + { + parser.inline_module_stack.emplace_back (std::move (name)); + } + ~InlineModuleStackScope () { parser.inline_module_stack.pop_back (); } + }; }; + +std::string +extract_module_path (const AST::AttrVec &inner_attrs, + const AST::AttrVec &outer_attrs, const std::string &name); } // namespace Rust // as now template, include implementations of all methods |