diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-09-27 05:26:17 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-27 05:26:17 +0000 |
commit | cecd314884a285957a110560bbd141a5f39ad7d3 (patch) | |
tree | 533af670fe654b937bece6d89ef28694e0defecd /gcc/rust/ast | |
parent | 8ed1bbaa40527c561b25b5dadb963ca404f2da37 (diff) | |
parent | 1c19256b70634ab62eeddefed58556bfc4912a90 (diff) | |
download | gcc-cecd314884a285957a110560bbd141a5f39ad7d3.zip gcc-cecd314884a285957a110560bbd141a5f39ad7d3.tar.gz gcc-cecd314884a285957a110560bbd141a5f39ad7d3.tar.bz2 |
Merge #1521
1521: expand: eager evaluate macros inside builtin macros r=CohenArthur a=liushuyu
- expand: eagerly evaluate the macros inside some of the builtin macros
Co-authored-by: liushuyu <liushuyu011@gmail.com>
Diffstat (limited to 'gcc/rust/ast')
-rw-r--r-- | gcc/rust/ast/rust-ast.h | 12 | ||||
-rw-r--r-- | gcc/rust/ast/rust-expr.h | 2 |
2 files changed, 14 insertions, 0 deletions
diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h index e9e16e7..492faea 100644 --- a/gcc/rust/ast/rust-ast.h +++ b/gcc/rust/ast/rust-ast.h @@ -31,6 +31,7 @@ namespace Rust { typedef std::string Identifier; typedef int TupleIndex; struct Session; +struct MacroExpander; namespace AST { // foward decl: ast visitor @@ -951,6 +952,8 @@ public: virtual Location get_locus () const = 0; + virtual bool is_literal () const { return false; } + // HACK: strictly not needed, but faster than full downcast clone virtual bool is_expr_without_block () const = 0; @@ -1471,6 +1474,7 @@ private: // One way of parsing the macro. Probably not applicable for all macros. std::vector<std::unique_ptr<MetaItemInner> > parsed_items; bool parsed_to_meta_item = false; + MacroExpander *expander = nullptr; public: std::string as_string () const; @@ -1495,6 +1499,7 @@ public: path = other.path; token_tree = other.token_tree; parsed_to_meta_item = other.parsed_to_meta_item; + expander = other.expander; parsed_items.reserve (other.parsed_items.size ()); for (const auto &e : other.parsed_items) @@ -1523,6 +1528,13 @@ public: SimplePath &get_path () { return path; } const SimplePath &get_path () const { return path; } + void set_expander (MacroExpander *new_expander) { expander = new_expander; } + MacroExpander *get_expander () + { + rust_assert (expander); + return expander; + } + void set_meta_item_output (std::vector<std::unique_ptr<MetaItemInner> > new_items) { diff --git a/gcc/rust/ast/rust-expr.h b/gcc/rust/ast/rust-expr.h index 1966a59..c764f9c 100644 --- a/gcc/rust/ast/rust-expr.h +++ b/gcc/rust/ast/rust-expr.h @@ -67,6 +67,8 @@ public: Location get_locus () const override final { return locus; } + bool is_literal () const override final { return true; } + Literal get_literal () const { return literal; } void accept_vis (ASTVisitor &vis) override; |