From 3f317ede41d69a8fd5e1690c4ed509a4e826ea11 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Tue, 3 May 2011 13:03:32 -0700 Subject: [PATCH] rustc: Name type glue properly --- src/comp/middle/trans.rs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index e8138392d79..4c9e299045f 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -184,7 +184,7 @@ fn path_name(vec[str] path) -> str { } -fn mangle_name_by_type(@crate_ctxt ccx, vec[str] path, ty.t t) -> str { +fn get_type_sha1(@crate_ctxt ccx, ty.t t) -> str { auto hash = ""; alt (ccx.type_sha1s.find(t)) { case (some[str](?h)) { hash = h; } @@ -200,9 +200,24 @@ fn mangle_name_by_type(@crate_ctxt ccx, vec[str] path, ty.t t) -> str { ccx.type_sha1s.insert(t, hash); } } + ret hash; +} + +fn mangle_name_by_type(@crate_ctxt ccx, vec[str] path, ty.t t) -> str { + auto hash = get_type_sha1(ccx, t); ret sep() + "rust" + sep() + hash + sep() + path_name(path); } +fn mangle_name_by_type_only(@crate_ctxt ccx, ty.t t, str name) -> str { + auto f = metadata.def_to_str; + auto cx = @rec(ds=f, tcx=ccx.tcx, + use_abbrevs=false, abbrevs=ccx.type_abbrevs); + auto s = metadata.Encode.ty_str(cx, t); + + auto hash = get_type_sha1(ccx, t); + ret sep() + "rust" + sep() + hash + sep() + name + "_" + s; +} + fn mangle_name_by_seq(@crate_ctxt ccx, vec[str] path, str flav) -> str { ret sep() + "rust" + sep() + ccx.names.next(flav) + sep() @@ -1774,8 +1789,7 @@ fn declare_generic_glue(@local_ctxt cx, ty.t t, TypeRef llfnty, str name) -> ValueRef { - auto gcx = @rec(path=vec("glue", name) with *cx); - auto fn_nm = mangle_name_by_seq(cx.ccx, cx.path, "glue"); + auto fn_nm = mangle_name_by_type_only(cx.ccx, t, "glue_" + name); fn_nm = sanitize(fn_nm); auto llfn = decl_internal_fastcall_fn(cx.ccx.llmod, fn_nm, llfnty); ret llfn; -- GitLab