diff options
author | CohenArthur <arthur.cohen@epita.fr> | 2021-05-18 19:27:12 +0200 |
---|---|---|
committer | CohenArthur <arthur.cohen@epita.fr> | 2021-05-18 19:30:20 +0200 |
commit | 30e9cfbf6a60b034a85077b4dd242a2760180188 (patch) | |
tree | 13fde879791ee47d52e39f6e6700cdde02767934 | |
parent | 4d71539414ca4e5edb51556b136b0b5eaee9a084 (diff) | |
download | gcc-30e9cfbf6a60b034a85077b4dd242a2760180188.zip gcc-30e9cfbf6a60b034a85077b4dd242a2760180188.tar.gz gcc-30e9cfbf6a60b034a85077b4dd242a2760180188.tar.bz2 |
name-resolver: Add NodeId to CanonicalPath lookup and reverse mappings
-rw-r--r-- | gcc/rust/resolve/rust-name-resolver.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/gcc/rust/resolve/rust-name-resolver.h b/gcc/rust/resolve/rust-name-resolver.h index 205c877..e45847e 100644 --- a/gcc/rust/resolve/rust-name-resolver.h +++ b/gcc/rust/resolve/rust-name-resolver.h @@ -114,6 +114,7 @@ public: } mappings[path] = id; + reverse_mappings.insert (std::pair<NodeId, CanonicalPath> (id, path)); decls_within_rib.insert (std::pair<NodeId, Location> (id, locus)); references[id] = {}; } @@ -128,9 +129,21 @@ public: return true; } + bool lookup_canonical_path (const NodeId &id, CanonicalPath *ident) + { + auto it = reverse_mappings.find (id); + if (it == reverse_mappings.end ()) + return false; + + *ident = it->second; + return true; + } + void clear_name (const CanonicalPath &ident, NodeId id) { mappings.erase (ident); + reverse_mappings.erase (id); + for (auto &it : decls_within_rib) { if (it.first == id) @@ -194,6 +207,7 @@ private: CrateNum crate_num; NodeId node_id; std::map<CanonicalPath, NodeId> mappings; + std::map<NodeId, CanonicalPath> reverse_mappings; std::set<std::pair<NodeId, Location> > decls_within_rib; std::map<NodeId, std::set<NodeId> > references; }; |