mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-11 08:05:12 +00:00
rustc: Don't give variables the same name as enums in trans
Conflicts: src/rustc/middle/trans/alt.rs src/rustc/middle/trans/base.rs src/rustc/middle/trans/closure.rs src/rustc/middle/trans/impl.rs src/rustc/middle/trans/uniq.rs
This commit is contained in:
parent
6cf5910de2
commit
c1157161d9
@ -461,8 +461,8 @@ fn compile_submatch(bcx: block, m: match, vals: [ValueRef]/~,
|
||||
|
||||
// Unbox in case of a box field
|
||||
if any_box_pat(m, col) {
|
||||
let box = Load(bcx, val);
|
||||
let box_no_addrspace = non_gc_box_cast(bcx, box);
|
||||
let llbox = Load(bcx, val);
|
||||
let box_no_addrspace = non_gc_box_cast(bcx, llbox);
|
||||
let unboxed =
|
||||
GEPi(bcx, box_no_addrspace, [0u, abi::box_field_body]/~);
|
||||
compile_submatch(bcx, enter_box(dm, m, col, val), [unboxed]/~
|
||||
@ -471,8 +471,8 @@ fn compile_submatch(bcx: block, m: match, vals: [ValueRef]/~,
|
||||
}
|
||||
|
||||
if any_uniq_pat(m, col) {
|
||||
let box = Load(bcx, val);
|
||||
let box_no_addrspace = non_gc_box_cast(bcx, box);
|
||||
let llbox = Load(bcx, val);
|
||||
let box_no_addrspace = non_gc_box_cast(bcx, llbox);
|
||||
let unboxed =
|
||||
GEPi(bcx, box_no_addrspace, [0u, abi::box_field_body]/~);
|
||||
compile_submatch(bcx, enter_uniq(dm, m, col, val),
|
||||
@ -553,11 +553,11 @@ fn compile_submatch(bcx: block, m: match, vals: [ValueRef]/~,
|
||||
trans_compare(bcx, ast::eq, test_val, t, val, t)
|
||||
}
|
||||
range_result({val: vbegin, _}, {bcx, val: vend}) {
|
||||
let {bcx, val: ge} = trans_compare(
|
||||
let {bcx, val: llge} = trans_compare(
|
||||
bcx, ast::ge, test_val, t, vbegin, t);
|
||||
let {bcx, val: le} = trans_compare(
|
||||
let {bcx, val: llle} = trans_compare(
|
||||
bcx, ast::le, test_val, t, vend, t);
|
||||
{bcx: bcx, val: And(bcx, ge, le)}
|
||||
{bcx: bcx, val: And(bcx, llge, llle)}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -744,15 +744,15 @@ fn bind_irrefutable_pat(bcx: block, pat: @ast::pat, val: ValueRef,
|
||||
}
|
||||
}
|
||||
ast::pat_box(inner) {
|
||||
let box = Load(bcx, val);
|
||||
let llbox = Load(bcx, val);
|
||||
let unboxed =
|
||||
GEPi(bcx, box, [0u, abi::box_field_body]/~);
|
||||
GEPi(bcx, llbox, [0u, abi::box_field_body]/~);
|
||||
bcx = bind_irrefutable_pat(bcx, inner, unboxed, true);
|
||||
}
|
||||
ast::pat_uniq(inner) {
|
||||
let box = Load(bcx, val);
|
||||
let llbox = Load(bcx, val);
|
||||
let unboxed =
|
||||
GEPi(bcx, box, [0u, abi::box_field_body]/~);
|
||||
GEPi(bcx, llbox, [0u, abi::box_field_body]/~);
|
||||
bcx = bind_irrefutable_pat(bcx, inner, unboxed, true);
|
||||
}
|
||||
ast::pat_wild | ast::pat_lit(_) | ast::pat_range(_, _) { }
|
||||
|
@ -386,10 +386,10 @@ fn malloc_raw(bcx: block, t: ty::t, heap: heap) -> ValueRef {
|
||||
fn malloc_general_dyn(bcx: block, t: ty::t, heap: heap, size: ValueRef) ->
|
||||
{box: ValueRef, body: ValueRef} {
|
||||
let _icx = bcx.insn_ctxt("malloc_general");
|
||||
let box = malloc_raw_dyn(bcx, t, heap, size);
|
||||
let non_gc_box = non_gc_box_cast(bcx, box);
|
||||
let llbox = malloc_raw_dyn(bcx, t, heap, size);
|
||||
let non_gc_box = non_gc_box_cast(bcx, llbox);
|
||||
let body = GEPi(bcx, non_gc_box, [0u, abi::box_field_body]/~);
|
||||
ret {box: box, body: body};
|
||||
ret {box: llbox, body: body};
|
||||
}
|
||||
|
||||
fn malloc_general(bcx: block, t: ty::t, heap: heap) ->
|
||||
@ -652,8 +652,8 @@ fn make_take_glue(bcx: block, v: ValueRef, t: ty::t) {
|
||||
closure::make_fn_glue(bcx, v, t, take_ty)
|
||||
}
|
||||
ty::ty_iface(_, _) {
|
||||
let box = Load(bcx, GEPi(bcx, v, [0u, 1u]/~));
|
||||
incr_refcnt_of_boxed(bcx, box);
|
||||
let llbox = Load(bcx, GEPi(bcx, v, [0u, 1u]/~));
|
||||
incr_refcnt_of_boxed(bcx, llbox);
|
||||
bcx
|
||||
}
|
||||
ty::ty_opaque_closure_ptr(ck) {
|
||||
@ -806,8 +806,8 @@ fn make_drop_glue(bcx: block, v0: ValueRef, t: ty::t) {
|
||||
closure::make_fn_glue(bcx, v0, t, drop_ty)
|
||||
}
|
||||
ty::ty_iface(_, _) {
|
||||
let box = Load(bcx, GEPi(bcx, v0, [0u, 1u]/~));
|
||||
decr_refcnt_maybe_free(bcx, box, ty::mk_opaque_box(ccx.tcx))
|
||||
let llbox = Load(bcx, GEPi(bcx, v0, [0u, 1u]/~));
|
||||
decr_refcnt_maybe_free(bcx, llbox, ty::mk_opaque_box(ccx.tcx))
|
||||
}
|
||||
ty::ty_opaque_closure_ptr(ck) {
|
||||
closure::make_opaque_cbox_drop_glue(bcx, ck, v0)
|
||||
@ -1518,10 +1518,10 @@ fn trans_unary(bcx: block, op: ast::unop, e: @ast::expr,
|
||||
}
|
||||
ast::neg {
|
||||
let {bcx, val} = trans_temp_expr(bcx, e);
|
||||
let neg = if ty::type_is_fp(e_ty) {
|
||||
let llneg = if ty::type_is_fp(e_ty) {
|
||||
FNeg(bcx, val)
|
||||
} else { Neg(bcx, val) };
|
||||
store_in_dest(bcx, neg, dest)
|
||||
store_in_dest(bcx, llneg, dest)
|
||||
}
|
||||
ast::box(_) {
|
||||
trans_boxed_expr(bcx, e, e_ty, heap_shared, dest)
|
||||
@ -2158,7 +2158,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id,
|
||||
}
|
||||
|
||||
let tpt = ty::lookup_item_type(ccx.tcx, fn_id);
|
||||
let mut item_ty = tpt.ty;
|
||||
let mut llitem_ty = tpt.ty;
|
||||
|
||||
let map_node = session::expect(ccx.sess, ccx.tcx.items.find(fn_id.node),
|
||||
{|| #fmt("While monomorphizing %?, couldn't find it in the item map \
|
||||
@ -2190,7 +2190,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id,
|
||||
ccx.tcx.sess.bug("Can't monomorphize a local")
|
||||
}
|
||||
};
|
||||
let mono_ty = ty::subst_tps(ccx.tcx, substs, item_ty);
|
||||
let mono_ty = ty::subst_tps(ccx.tcx, substs, llitem_ty);
|
||||
let llfty = type_of_fn_from_ty(ccx, mono_ty);
|
||||
|
||||
let depth = option::get_default(ccx.monomorphizing.find(fn_id), 0u);
|
||||
@ -2543,12 +2543,12 @@ fn trans_rec_field(bcx: block, base: @ast::expr,
|
||||
|
||||
fn trans_rec_field_inner(bcx: block, val: ValueRef, ty: ty::t,
|
||||
field: ast::ident, sp: span) -> lval_result {
|
||||
let mut deref = false;
|
||||
let mut llderef = false;
|
||||
let fields = alt ty::get(ty).struct {
|
||||
ty::ty_rec(fs) { fs }
|
||||
ty::ty_class(did, substs) {
|
||||
if option::is_some(ty::ty_dtor(bcx.tcx(), did)) {
|
||||
deref = true;
|
||||
llderef = true;
|
||||
}
|
||||
ty::class_items_as_mutable_fields(bcx.tcx(), did, substs)
|
||||
}
|
||||
@ -2567,7 +2567,7 @@ fn trans_rec_field_inner(bcx: block, val: ValueRef, ty: ty::t,
|
||||
have to select out the object itself
|
||||
(If any other code does the same thing, that's
|
||||
a bug */
|
||||
let val = if deref {
|
||||
let val = if llderef {
|
||||
GEPi(bcx, GEPi(bcx, val, [0u, 1u]/~), [0u, ix]/~)
|
||||
}
|
||||
else { GEPi(bcx, val, [0u, ix]/~) };
|
||||
|
@ -150,21 +150,21 @@ fn allocate_cbox(bcx: block,
|
||||
let _icx = bcx.insn_ctxt("closure::allocate_cbox");
|
||||
let ccx = bcx.ccx(), tcx = ccx.tcx;
|
||||
|
||||
fn nuke_ref_count(bcx: block, box: ValueRef) {
|
||||
fn nuke_ref_count(bcx: block, llbox: ValueRef) {
|
||||
let _icx = bcx.insn_ctxt("closure::nuke_ref_count");
|
||||
// Initialize ref count to arbitrary value for debugging:
|
||||
let ccx = bcx.ccx();
|
||||
let box = PointerCast(bcx, box, T_opaque_box_ptr(ccx));
|
||||
let ref_cnt = GEPi(bcx, box, [0u, abi::box_field_refcnt]/~);
|
||||
let llbox = PointerCast(bcx, llbox, T_opaque_box_ptr(ccx));
|
||||
let ref_cnt = GEPi(bcx, llbox, [0u, abi::box_field_refcnt]/~);
|
||||
let rc = C_int(ccx, 0x12345678);
|
||||
Store(bcx, rc, ref_cnt);
|
||||
}
|
||||
|
||||
fn store_tydesc(bcx: block,
|
||||
cdata_ty: ty::t,
|
||||
box: ValueRef,
|
||||
llbox: ValueRef,
|
||||
&ti: option<@tydesc_info>) -> block {
|
||||
let bound_tydesc = GEPi(bcx, box, [0u, abi::box_field_tydesc]/~);
|
||||
let bound_tydesc = GEPi(bcx, llbox, [0u, abi::box_field_tydesc]/~);
|
||||
let td = base::get_tydesc(bcx.ccx(), cdata_ty, ti);
|
||||
Store(bcx, td, bound_tydesc);
|
||||
bcx
|
||||
@ -173,21 +173,21 @@ fn allocate_cbox(bcx: block,
|
||||
// Allocate and initialize the box:
|
||||
let mut ti = none;
|
||||
let mut temp_cleanups = []/~;
|
||||
let (bcx, box) = alt ck {
|
||||
let (bcx, llbox) = alt ck {
|
||||
ty::ck_box {
|
||||
get_tydesc(ccx, cdata_ty, ti);
|
||||
let box = malloc_raw(bcx, cdata_ty, heap_shared);
|
||||
(bcx, box)
|
||||
let llbox = malloc_raw(bcx, cdata_ty, heap_shared);
|
||||
(bcx, llbox)
|
||||
}
|
||||
ty::ck_uniq {
|
||||
let box = malloc_raw(bcx, cdata_ty, heap_exchange);
|
||||
(bcx, box)
|
||||
let llbox = malloc_raw(bcx, cdata_ty, heap_exchange);
|
||||
(bcx, llbox)
|
||||
}
|
||||
ty::ck_block {
|
||||
let cbox_ty = tuplify_box_ty(tcx, cdata_ty);
|
||||
let box = base::alloc_ty(bcx, cbox_ty);
|
||||
nuke_ref_count(bcx, box);
|
||||
(bcx, box)
|
||||
let llbox = base::alloc_ty(bcx, cbox_ty);
|
||||
nuke_ref_count(bcx, llbox);
|
||||
(bcx, llbox)
|
||||
}
|
||||
};
|
||||
|
||||
@ -195,7 +195,7 @@ fn allocate_cbox(bcx: block,
|
||||
base::lazily_emit_tydesc_glue(ccx, abi::tydesc_field_drop_glue, ti);
|
||||
base::lazily_emit_tydesc_glue(ccx, abi::tydesc_field_free_glue, ti);
|
||||
|
||||
ret (bcx, box, temp_cleanups);
|
||||
ret (bcx, llbox, temp_cleanups);
|
||||
}
|
||||
|
||||
type closure_result = {
|
||||
|
@ -150,10 +150,10 @@ fn trans_iface_callee(bcx: block, val: ValueRef,
|
||||
let ccx = bcx.ccx();
|
||||
let vtable = Load(bcx, PointerCast(bcx, GEPi(bcx, val, [0u, 0u]/~),
|
||||
T_ptr(T_ptr(T_vtable()))));
|
||||
let box = Load(bcx, GEPi(bcx, val, [0u, 1u]/~));
|
||||
let llbox = Load(bcx, GEPi(bcx, val, [0u, 1u]/~));
|
||||
// FIXME[impl] I doubt this is alignment-safe (#2534)
|
||||
let self = GEPi(bcx, box, [0u, abi::box_field_body]/~);
|
||||
let env = self_env(self, ty::mk_opaque_box(bcx.tcx()), some(box));
|
||||
let self = GEPi(bcx, llbox, [0u, abi::box_field_body]/~);
|
||||
let env = self_env(self, ty::mk_opaque_box(bcx.tcx()), some(llbox));
|
||||
let llfty = type_of::type_of_fn_from_ty(ccx, callee_ty);
|
||||
let vtable = PointerCast(bcx, vtable,
|
||||
T_ptr(T_array(T_ptr(llfty), n_method + 1u)));
|
||||
@ -284,13 +284,13 @@ fn trans_cast(bcx: block, val: @ast::expr, id: ast::node_id, dest: dest)
|
||||
if dest == ignore { ret trans_expr(bcx, val, ignore); }
|
||||
let ccx = bcx.ccx();
|
||||
let v_ty = expr_ty(bcx, val);
|
||||
let {box, body} = malloc_boxed(bcx, v_ty);
|
||||
add_clean_free(bcx, box, heap_shared);
|
||||
let {box: llbox, body: body} = malloc_boxed(bcx, v_ty);
|
||||
add_clean_free(bcx, llbox, heap_shared);
|
||||
let bcx = trans_expr_save_in(bcx, val, body);
|
||||
revoke_clean(bcx, box);
|
||||
revoke_clean(bcx, llbox);
|
||||
let result = get_dest_addr(dest);
|
||||
Store(bcx, box, PointerCast(bcx, GEPi(bcx, result, [0u, 1u]/~),
|
||||
T_ptr(val_ty(box))));
|
||||
Store(bcx, llbox, PointerCast(bcx, GEPi(bcx, result, [0u, 1u]/~),
|
||||
T_ptr(val_ty(llbox))));
|
||||
let orig = ccx.maps.vtable_map.get(id)[0];
|
||||
let orig = resolve_vtable_in_fn_ctxt(bcx.fcx, orig);
|
||||
let vtable = get_vtable(bcx.ccx(), orig);
|
||||
|
Loading…
Reference in New Issue
Block a user