diff options
author | Philip Herron <philip.herron@embecosm.com> | 2021-08-19 21:12:31 +0100 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2021-08-20 13:32:14 +0100 |
commit | 048261647afd1a08f681b78c90c58a9baaeef76d (patch) | |
tree | 47dc551f706c4015c017a299a4054cb7db460857 /gcc/rust/backend/rust-compile.cc | |
parent | 1dc718474044149ec1aa6bee9ea8e83d778f17f2 (diff) | |
download | gcc-048261647afd1a08f681b78c90c58a9baaeef76d.zip gcc-048261647afd1a08f681b78c90c58a9baaeef76d.tar.gz gcc-048261647afd1a08f681b78c90c58a9baaeef76d.tar.bz2 |
Add qualified path support
Qualified paths need to lookup the associated trait item and mangle the
names apropriatly.
Diffstat (limited to 'gcc/rust/backend/rust-compile.cc')
-rw-r--r-- | gcc/rust/backend/rust-compile.cc | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/gcc/rust/backend/rust-compile.cc b/gcc/rust/backend/rust-compile.cc index c36f848..baaccf0 100644 --- a/gcc/rust/backend/rust-compile.cc +++ b/gcc/rust/backend/rust-compile.cc @@ -553,6 +553,17 @@ mangle_name (const std::string &name) return std::to_string (name.size ()) + name; } +static std::string +mangle_canonical_path (const Resolver::CanonicalPath &path) +{ + std::string buffer; + path.iterate_segs ([&] (const Resolver::CanonicalPath &p) -> bool { + buffer += mangle_name (p.get ()); + return true; + }); + return buffer; +} + // rustc uses a sip128 hash for legacy mangling, but an fnv 128 was quicker to // implement for now static std::string @@ -603,17 +614,19 @@ mangle_self (const TyTy::BaseType *self) } std::string -Context::mangle_item (const TyTy::BaseType *ty, const std::string &name) const +Context::mangle_item (const TyTy::BaseType *ty, + const Resolver::CanonicalPath &path) const { const std::string &crate_name = mappings->get_current_crate_name (); const std::string hash = legacy_hash (ty->as_string ()); const std::string hash_sig = mangle_name (hash); - return kMangledSymbolPrefix + mangle_name (crate_name) + mangle_name (name) - + hash_sig + kMangledSymbolDelim; + return kMangledSymbolPrefix + mangle_name (crate_name) + + mangle_canonical_path (path) + hash_sig + kMangledSymbolDelim; } +// FIXME this is a wee bit broken std::string Context::mangle_impl_item (const TyTy::BaseType *self, const TyTy::BaseType *ty, const std::string &name) const |