diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-02-17 17:02:43 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-17 17:02:43 +0000 |
commit | 9fb06d66cef70584e7aa2fa3a6ad22ef7def6b84 (patch) | |
tree | d8ed1ea0d957afd906556ae89e8622f79c4690f1 /gcc/rust/resolve/rust-name-resolver.h | |
parent | 752bf6c80a922e09edf5bcb53e15e08e83057a7f (diff) | |
parent | 37415eec77438bba2fc61df3e9a396c1e2cbaca8 (diff) | |
download | gcc-9fb06d66cef70584e7aa2fa3a6ad22ef7def6b84.zip gcc-9fb06d66cef70584e7aa2fa3a6ad22ef7def6b84.tar.gz gcc-9fb06d66cef70584e7aa2fa3a6ad22ef7def6b84.tar.bz2 |
Merge #938
938: First pass at declarative macro expansion r=philberty a=philberty
This does not support repetition matchers but it supports simple
declarative macros and transcribes them. The approach taken here is that
we reuse our existing parser to call the apropriate functions as specified
as part of the MacroFragmentType enum if the parser does not have errors
parsing that item then it must be a match.
Then once we match a rule we have a map of the token begin/end offsets
for each fragment match, this is then used to adjust and create a new token
stream for the macro rule definition so that when we feed it to the parser
the tokens are already substituted. The resulting expression or item is
then attached to the respective macro invocation and this is then name
resolved and used for hir lowering.
Fixes #17 #22
Addresses #573
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
Diffstat (limited to 'gcc/rust/resolve/rust-name-resolver.h')
-rw-r--r-- | gcc/rust/resolve/rust-name-resolver.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/gcc/rust/resolve/rust-name-resolver.h b/gcc/rust/resolve/rust-name-resolver.h index 199b0f9..2084480 100644 --- a/gcc/rust/resolve/rust-name-resolver.h +++ b/gcc/rust/resolve/rust-name-resolver.h @@ -274,10 +274,12 @@ public: void push_new_name_rib (Rib *r); void push_new_type_rib (Rib *r); void push_new_label_rib (Rib *r); + void push_new_macro_rib (Rib *r); bool find_name_rib (NodeId id, Rib **rib); bool find_type_rib (NodeId id, Rib **rib); bool find_label_rib (NodeId id, Rib **rib); + bool find_macro_rib (NodeId id, Rib **rib); void insert_new_definition (NodeId id, Definition def); bool lookup_definition (NodeId id, Definition *def); @@ -291,10 +293,14 @@ public: void insert_resolved_label (NodeId refId, NodeId defId); bool lookup_resolved_label (NodeId refId, NodeId *defId); + void insert_resolved_macro (NodeId refId, NodeId defId); + bool lookup_resolved_macro (NodeId refId, NodeId *defId); + // proxy for scoping Scope &get_name_scope () { return name_scope; } Scope &get_type_scope () { return type_scope; } Scope &get_label_scope () { return label_scope; } + Scope &get_macro_scope () { return macro_scope; } NodeId get_global_type_node_id () { return global_type_node_id; } @@ -371,6 +377,7 @@ private: Scope name_scope; Scope type_scope; Scope label_scope; + Scope macro_scope; NodeId global_type_node_id; NodeId unit_ty_node_id; @@ -379,6 +386,7 @@ private: std::map<NodeId, Rib *> name_ribs; std::map<NodeId, Rib *> type_ribs; std::map<NodeId, Rib *> label_ribs; + std::map<NodeId, Rib *> macro_ribs; // map any Node to its Definition // ie any name or type usage @@ -395,6 +403,7 @@ private: std::map<NodeId, NodeId> resolved_names; std::map<NodeId, NodeId> resolved_types; std::map<NodeId, NodeId> resolved_labels; + std::map<NodeId, NodeId> resolved_macros; // map of resolved names mutability flag std::map<NodeId, bool> decl_mutability; |