summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-12-04 12:06:39 +0800
committerJohn Hodge <tpg@mutabah.net>2016-12-04 12:06:39 +0800
commitd3606dcb5f4bca2f26524956231cf5b057a95cac (patch)
treeea3280a41b99e1c9da7dff15425a576aa3555b94
parent1f9e3bef9c395d792db1ea5e54b2b57a6dae4510 (diff)
downloadmrust-d3606dcb5f4bca2f26524956231cf5b057a95cac.tar.gz
Trans - Mangled names for Ufcs*
-rw-r--r--src/trans/codegen_c.cpp18
-rw-r--r--src/trans/mangling.cpp40
2 files changed, 51 insertions, 7 deletions
diff --git a/src/trans/codegen_c.cpp b/src/trans/codegen_c.cpp
index a0215a32..6d331e65 100644
--- a/src/trans/codegen_c.cpp
+++ b/src/trans/codegen_c.cpp
@@ -279,13 +279,21 @@ namespace {
{
emit_ctype( params.monomorph(m_crate, item.m_return) );
m_of << " " << Trans_Mangle(p) << "(";
- for(unsigned int i = 0; i < item.m_args.size(); i ++)
+ if( item.m_args.size() == 0 )
{
- if( i != 0 ) m_of << ", ";
- emit_ctype( params.monomorph(m_crate, item.m_args[i].second) );
- m_of << " arg" << i;
+ m_of << "void)";
+ }
+ else
+ {
+ for(unsigned int i = 0; i < item.m_args.size(); i ++)
+ {
+ if( i != 0 ) m_of << ",";
+ m_of << "\n\t\t";
+ emit_ctype( params.monomorph(m_crate, item.m_args[i].second) );
+ m_of << " arg" << i;
+ }
+ m_of << "\n\t\t)";
}
- m_of << ")";
}
void emit_lvalue(const ::MIR::LValue& val) {
TU_MATCHA( (val), (e),
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 "";