"Narrow scope forgives many sins." -- M. Schwern

This commit is contained in:
Lindsey Kuper 2011-07-12 11:59:21 -07:00
parent a9b77a5011
commit a0b78e649e
1 changed files with 14 additions and 15 deletions

View File

@ -7129,7 +7129,6 @@ fn trans_anon_obj(@block_ctxt bcx, &span sp, &ast::anon_obj anon_obj,
methods = anon_obj.methods,
dtor = none[@ast::method]);
let option::t[result] with_obj_val = none;
let ty::t with_obj_ty;
auto vtbl;
alt (anon_obj.with_obj) {
@ -7152,11 +7151,6 @@ fn trans_anon_obj(@block_ctxt bcx, &span sp, &ast::anon_obj anon_obj,
additional_field_tys);
}
case (some(?e)) {
// If with_obj (the object being extended) exists, translate it.
// Translating with_obj returns a ValueRef (pointer to a 2-word
// value) wrapped in a result.
with_obj_val = some(trans_expr(bcx, e));
// TODO: What makes more sense to get the type of an expr --
// calling ty::expr_ty(ccx.tcx, e) on it or calling
// ty::node_id_to_type(ccx.tcx, id) on its id?
@ -7327,17 +7321,22 @@ fn trans_anon_obj(@block_ctxt bcx, &span sp, &ast::anon_obj anon_obj,
i += 1;
}
// Copy a pointer to the with_obj into the object's body.
auto body_with_obj =
GEP_tup_like(bcx, body_ty, body.val,
~[0, abi::obj_body_elt_with_obj]);
bcx = body_with_obj.bcx;
alt (with_obj_val) {
case (some(?v)) {
// If there's a with_obj, copy a pointer to it into the object's body.
alt (anon_obj.with_obj) {
case (none) { }
case (some(?e)) {
// If with_obj (the object being extended) exists, translate
// it. Translating with_obj returns a ValueRef (pointer to a
// 2-word value) wrapped in a result.
let result with_obj_val = trans_expr(bcx, e);
auto body_with_obj =
GEP_tup_like(bcx, body_ty, body.val,
~[0, abi::obj_body_elt_with_obj]);
bcx = body_with_obj.bcx;
bcx = copy_val(bcx, INIT, body_with_obj.val,
v.val, with_obj_ty).bcx;
with_obj_val.val, with_obj_ty).bcx;
}
case (_) {}
}
// Store box ptr in outer pair.