diff options
author | John Hodge <tpg@mutabah.net> | 2016-12-04 12:06:39 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-12-04 12:06:39 +0800 |
commit | d3606dcb5f4bca2f26524956231cf5b057a95cac (patch) | |
tree | ea3280a41b99e1c9da7dff15425a576aa3555b94 /src/trans/mangling.cpp | |
parent | 1f9e3bef9c395d792db1ea5e54b2b57a6dae4510 (diff) | |
download | mrust-d3606dcb5f4bca2f26524956231cf5b057a95cac.tar.gz |
Trans - Mangled names for Ufcs*
Diffstat (limited to 'src/trans/mangling.cpp')
-rw-r--r-- | src/trans/mangling.cpp | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/src/trans/mangling.cpp b/src/trans/mangling.cpp index c5c568d9..339a5a35 100644 --- a/src/trans/mangling.cpp +++ b/src/trans/mangling.cpp @@ -12,18 +12,40 @@ * $R = &-ptr * $P = + symbol * $E = = symbol + * $C = , symbol * $pL/$pR = Left/right paren + * $aL/$aR = Left/right angle (<>) */ #include "mangling.hpp" #include <hir/type.hpp> #include <hir/path.hpp> +namespace { + ::FmtLambda emit_params(const ::HIR::PathParams& params) + { + return FMT_CB(ss, + if( params.m_types.size() > 0 ) + { + ss << "$aL"; + for(unsigned int i = 0; i < params.m_types.size(); i ++) + { + if(i != 0) ss << "$C"; + ss << Trans_Mangle( params.m_types[i] ); + } + ss << "$aR"; + } + ); + } +} + + ::FmtLambda Trans_Mangle(const ::HIR::GenericPath& path) { return FMT_CB(ss, ss << "_ZN" << path.m_path.m_crate_name.size() << path.m_path.m_crate_name; for(const auto& comp : path.m_path.m_components) ss << comp.size() << comp; + ss << emit_params(path.m_params); ); } ::FmtLambda Trans_Mangle(const ::HIR::Path& path) @@ -36,10 +58,24 @@ BUG(Span(), "UfcsUnknown - " << path); ), (UfcsKnown, - return FMT_CB(ss, ss << "/*ufcsknown*/";); + return FMT_CB(ss, + ss << "_ZRK$aL"; + ss << Trans_Mangle(*pe.type); + ss << "_as_"; + ss << Trans_Mangle(pe.trait); + ss << "$aR"; + ss << pe.item; + ss << emit_params(pe.params); + ); ), (UfcsInherent, - return FMT_CB(ss, ss << "/*ufcsinherent*/"; ); + return FMT_CB(ss, + ss << "_ZRI$aL"; + ss << Trans_Mangle(*pe.type); + ss << "$aR"; + ss << pe.item; + ss << emit_params(pe.params); + ); ) ) throw ""; |