diff options
author | Arthur Cohen <arthur.cohen@embecosm.com> | 2023-02-08 12:23:06 +0100 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2023-04-06 10:47:22 +0200 |
commit | fbd5244df6bd36d7083464e61e0e62047caf2413 (patch) | |
tree | 5e9229104716010f2b7fe74cb10d7a9b7ead0789 /gcc/rust | |
parent | 3821669164d6d925de393470447e91c31bc78074 (diff) | |
download | gcc-fbd5244df6bd36d7083464e61e0e62047caf2413.zip gcc-fbd5244df6bd36d7083464e61e0e62047caf2413.tar.gz gcc-fbd5244df6bd36d7083464e61e0e62047caf2413.tar.bz2 |
gccrs: expander: Add documentation for `expand_eager_invocations`
gcc/rust/ChangeLog:
* expand/rust-macro-expand.cc (MacroExpander::expand_eager_invocations):
Add documentation explaining the algorithm.
Diffstat (limited to 'gcc/rust')
-rw-r--r-- | gcc/rust/expand/rust-macro-expand.cc | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/gcc/rust/expand/rust-macro-expand.cc b/gcc/rust/expand/rust-macro-expand.cc index 0ff849d..4b49449 100644 --- a/gcc/rust/expand/rust-macro-expand.cc +++ b/gcc/rust/expand/rust-macro-expand.cc @@ -197,17 +197,25 @@ MacroExpander::expand_eager_invocations (AST::MacroInvocation &invoc) auto start = kv.first.first; auto end = kv.first.second; - // TODO: Add doc + // We're now going to re-add the tokens to the invocation's token tree. + // 1. Basically, what we want to do is insert all tokens up until the + // beginning of the macro invocation (start). + // 2. Then, we'll insert all of the tokens resulting from the macro + // expansion: These are in `new_tokens`. + // 3. Finally, we'll do that again from + // the end of macro and go back to 1. + for (size_t i = current_idx; i < start; i++) new_stream.emplace_back (stream[i]->clone_token ()); - // TODO: Add doc for (auto &tok : new_tokens) new_stream.emplace_back (tok->clone_token ()); current_idx = end; } - // TODO: Add doc + + // Once all of that is done, we copy the last remaining tokens from the + // original stream for (size_t i = current_idx; i < stream.size (); i++) new_stream.emplace_back (stream[i]->clone_token ()); |