diff options
author | Arthur Cohen <arthur.cohen@embecosm.com> | 2022-08-23 16:15:22 +0100 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2022-12-13 14:00:04 +0100 |
commit | 1841081a8a306c1a220694a5ddb3a927cb4b2db3 (patch) | |
tree | 5ed5a29b6188aa40af30a4ab469306e9a8b1bfc0 /gcc/rust/resolve/rust-ast-resolve.cc | |
parent | 32c8fb0eeafb1ec47f75242cb28171fcbdbf6e8e (diff) | |
download | gcc-1841081a8a306c1a220694a5ddb3a927cb4b2db3.zip gcc-1841081a8a306c1a220694a5ddb3a927cb4b2db3.tar.gz gcc-1841081a8a306c1a220694a5ddb3a927cb4b2db3.tar.bz2 |
gccrs: Add expansion pass for the Rust front-end
The expansion pass is responsible for two actions on our AST:
1. Expanding macro calls
2. Performing conditional compilation
Calls to macros should be checked and expanded into an AST fragment based on
the context they've been called in. This is similar to token substitution, with
a lot of intricacies and checks being performed. A single invocation can result
in an AST fragment containing multiple statements or multiple expressions,
which need to be handled as well. Furthermore, Rust macros can contain
repetitions relying on Kleine operators, similar to regular expression
patterns, that also need to be expanded properly.
Finally, Rust code can be hidden behind `cfg` directives, which allow the user
to perform conditional compilation. If a `cfg` predicate is not met, the
expression or statement it refers to should be marked for strip and removed
from the AST.
gcc/rust/
* expand/rust-attribute-visitor.cc: New.
* expand/rust-attribute-visitor.h: New.
* expand/rust-macro-builtins.cc: New.
* expand/rust-macro-builtins.h: New.
* expand/rust-macro-expand.cc: New.
* expand/rust-macro-expand.h: New.
* expand/rust-macro-invoc-lexer.cc: New.
* expand/rust-macro-invoc-lexer.h: New.
* expand/rust-macro-substitute-ctx.cc: New.
* expand/rust-macro-substitute-ctx.h: New.
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
Co-authored-by: Joel Phillips <simplytheother@gmail.com>
Signed-off-by: Joel Phillips <simplytheother@gmail.com>
Diffstat (limited to 'gcc/rust/resolve/rust-ast-resolve.cc')
0 files changed, 0 insertions, 0 deletions