|
1 | 1 | #include "rust-mangle.h"
|
2 | 2 | #include "fnv-hash.h"
|
| 3 | +#include <algorithm> |
3 | 4 |
|
4 | 5 | // FIXME: Rename those to legacy_*
|
5 | 6 | static const std::string kMangledSymbolPrefix = "_ZN";
|
@@ -154,6 +155,44 @@ v0_simple_type_prefix (const TyTy::BaseType *ty)
|
154 | 155 | gcc_unreachable ();
|
155 | 156 | }
|
156 | 157 |
|
| 158 | +// FIXME: Is this present somewhere in libbiberty already? |
| 159 | +static std::string |
| 160 | +v0_base62_integer(uint64_t x) |
| 161 | +{ |
| 162 | + const static std::string base_64 |
| 163 | + = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@$"; |
| 164 | + std::string buffer(128, '\0'); |
| 165 | + size_t idx = 0; |
| 166 | + size_t base = 62; |
| 167 | + |
| 168 | + do |
| 169 | + { |
| 170 | + buffer[idx] = base_64[(x % base)]; |
| 171 | + idx++; |
| 172 | + x /= base; |
| 173 | + } while (x != 0); |
| 174 | + |
| 175 | + std::reverse(buffer.begin(), buffer.begin() + idx); |
| 176 | + return buffer.substr(0, idx); |
| 177 | +} |
| 178 | + |
| 179 | +static std::string |
| 180 | +v0_add_integer_62 (std::string mangled, std::string tag, uint64_t x) |
| 181 | +{ |
| 182 | + // /// Push a `_`-terminated base 62 integer, using the format |
| 183 | + // /// specified in the RFC as `<base-62-number>`, that is: |
| 184 | + // /// * `x = 0` is encoded as just the `"_"` terminator |
| 185 | + // /// * `x > 0` is encoded as `x - 1` in base 62, followed by `"_"`, |
| 186 | + // /// e.g. `1` becomes `"0_"`, `62` becomes `"Z_"`, etc. |
| 187 | + // fn push_integer_62(&mut self, x: u64) { |
| 188 | + // if let Some(x) = x.checked_sub(1) { |
| 189 | + // base_n::push_str(x as u128, 62, &mut self.out); |
| 190 | + // } |
| 191 | + // self.push("_"); |
| 192 | + // } |
| 193 | +} |
| 194 | + |
| 195 | + |
157 | 196 | static std::string
|
158 | 197 | v0_type_prefix (const TyTy::BaseType *ty)
|
159 | 198 | {
|
@@ -194,7 +233,11 @@ static std::string
|
194 | 233 | v0_mangle_item (const TyTy::BaseType *ty, const Resolver::CanonicalPath &path,
|
195 | 234 | const std::string &crate_name)
|
196 | 235 | {
|
| 236 | + auto def_id = ty->get_ref(); |
197 | 237 | auto ty_prefix = v0_type_prefix (ty);
|
| 238 | + auto prefix = "_R"; |
| 239 | + |
| 240 | + |
198 | 241 | gcc_unreachable ();
|
199 | 242 | }
|
200 | 243 |
|
|
0 commit comments