rustc: Stop calling cmp shape glue in trans.

XFAIL's alt-borrowed_str for now. Will need to fix this up in the future.
This commit is contained in:
Patrick Walton 2012-09-10 17:22:20 -07:00
parent cb7a5395dd
commit 2aa67e9aa9
7 changed files with 47 additions and 10 deletions

View file

@ -747,6 +747,13 @@ pure fn eq_slice(a: &str, b: &str) -> bool {
}
/// Bytewise string equality
#[cfg(notest)]
#[lang="uniq_str_eq"]
pure fn eq(a: &~str, b: &~str) -> bool {
eq_slice(*a, *b)
}
#[cfg(test)]
pure fn eq(a: &~str, b: &~str) -> bool {
eq_slice(*a, *b)
}

View file

@ -206,7 +206,7 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg,
middle::region::determine_rp_in_crate(sess, ast_map, def_map, crate));
let ty_cx = ty::mk_ctxt(sess, def_map, ast_map, freevars,
region_map, rp_set);
region_map, rp_set, move lang_items);
let (method_map, vtable_map) = time(time_passes, ~"typechecking", ||
typeck::check_crate(ty_cx,

View file

@ -44,7 +44,8 @@ struct LanguageItems {
mut eq_trait: Option<def_id>,
mut ord_trait: Option<def_id>,
mut str_eq_fn: Option<def_id>
mut str_eq_fn: Option<def_id>,
mut uniq_str_eq_fn: Option<def_id>
}
mod LanguageItems {
@ -71,7 +72,8 @@ mod LanguageItems {
eq_trait: None,
ord_trait: None,
str_eq_fn: None
str_eq_fn: None,
uniq_str_eq_fn: None
}
}
}
@ -104,6 +106,7 @@ fn LanguageItemCollector(crate: @crate, session: session,
item_refs.insert(~"ord", &mut items.ord_trait);
item_refs.insert(~"str_eq", &mut items.str_eq_fn);
item_refs.insert(~"uniq_str_eq", &mut items.uniq_str_eq_fn);
LanguageItemCollector {
crate: crate,

View file

@ -436,10 +436,27 @@ fn compare_values(cx: block, lhs: ValueRef, rhs: ValueRef, rhs_t: ty::t) ->
return rslt(rs.bcx, rs.val);
}
// Determine the operation we need.
let llop = C_u8(abi::cmp_glue_op_eq);
let cmpval = glue::call_cmp_glue(cx, lhs, rhs, rhs_t, llop);
rslt(cx, cmpval)
match ty::get(rhs_t).struct {
ty::ty_estr(ty::vstore_uniq) => {
let scratch_result = scratch_datum(cx, ty::mk_bool(cx.tcx()),
false);
let scratch_lhs = alloca(cx, val_ty(lhs));
Store(cx, lhs, scratch_lhs);
let scratch_rhs = alloca(cx, val_ty(rhs));
Store(cx, rhs, scratch_rhs);
let did = cx.tcx().lang_items.uniq_str_eq_fn.get();
let bcx = callee::trans_rtcall_or_lang_call(cx, did,
~[scratch_lhs,
scratch_rhs],
expr::SaveIn(
scratch_result.val));
return scratch_result.to_result(bcx);
}
_ => {
cx.tcx().sess.bug(~"only scalars and unique strings supported in \
compare_values");
}
}
}
fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef],

View file

@ -273,6 +273,11 @@ fn trans_rtcall(bcx: block, name: ~str, args: ~[ValueRef], dest: expr::Dest)
-> block
{
let did = bcx.ccx().rtcalls[name];
return trans_rtcall_or_lang_call(bcx, did, args, dest);
}
fn trans_rtcall_or_lang_call(bcx: block, did: ast::def_id, args: ~[ValueRef],
dest: expr::Dest) -> block {
let fty = if did.crate == ast::local_crate {
ty::node_id_to_type(bcx.ccx().tcx, did.node)
} else {

View file

@ -342,7 +342,8 @@ type ctxt =
inferred_modes: HashMap<ast::node_id, ast::mode>,
// maps the id of borrowed expr to scope of borrowed ptr
borrowings: HashMap<ast::node_id, borrow>,
normalized_cache: HashMap<t, t>};
normalized_cache: HashMap<t, t>,
lang_items: middle::lang_items::LanguageItems};
enum tbox_flag {
has_params = 1,
@ -809,7 +810,8 @@ fn mk_ctxt(s: session::session,
amap: ast_map::map,
freevars: freevars::freevar_map,
region_map: middle::region::region_map,
region_paramd_items: middle::region::region_paramd_items) -> ctxt {
region_paramd_items: middle::region::region_paramd_items,
+lang_items: middle::lang_items::LanguageItems) -> ctxt {
let interner = map::HashMap();
let vecs_implicitly_copyable =
get_lint_level(s.lint_settings.default_settings,
@ -841,7 +843,8 @@ fn mk_ctxt(s: session::session,
ty_param_bounds: map::int_hash(),
inferred_modes: map::int_hash(),
borrowings: map::int_hash(),
normalized_cache: new_ty_hash()}
normalized_cache: new_ty_hash(),
lang_items: move lang_items}
}

View file

@ -1,3 +1,5 @@
// xfail-test
// xfail-fast
// -*- rust -*-
fn f1(ref_string: &str) {
match ref_string {