glue::trans_struct_drop -> adt
This commit is contained in:
parent
5ca4fdfc98
commit
71b6e945c1
@ -19,6 +19,7 @@ use back::link::*;
|
|||||||
use driver::session;
|
use driver::session;
|
||||||
use lib;
|
use lib;
|
||||||
use lib::llvm::{llvm, ValueRef, TypeRef, True};
|
use lib::llvm::{llvm, ValueRef, TypeRef, True};
|
||||||
|
use middle::trans::adt;
|
||||||
use middle::trans::base::*;
|
use middle::trans::base::*;
|
||||||
use middle::trans::callee;
|
use middle::trans::callee;
|
||||||
use middle::trans::closure;
|
use middle::trans::closure;
|
||||||
@ -447,10 +448,10 @@ pub fn make_free_glue(bcx: block, v: ValueRef, t: ty::t) {
|
|||||||
match ty::ty_dtor(bcx.tcx(), did) {
|
match ty::ty_dtor(bcx.tcx(), did) {
|
||||||
ty::NoDtor => bcx,
|
ty::NoDtor => bcx,
|
||||||
ty::LegacyDtor(ref dt_id) => {
|
ty::LegacyDtor(ref dt_id) => {
|
||||||
trans_struct_drop(bcx, v, *dt_id, did, substs, false)
|
trans_struct_drop(bcx, t, v, *dt_id, did, substs, false)
|
||||||
}
|
}
|
||||||
ty::TraitDtor(ref dt_id) => {
|
ty::TraitDtor(ref dt_id) => {
|
||||||
trans_struct_drop(bcx, v, *dt_id, did, substs, true)
|
trans_struct_drop(bcx, t, v, *dt_id, did, substs, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -460,6 +461,7 @@ pub fn make_free_glue(bcx: block, v: ValueRef, t: ty::t) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn trans_struct_drop(bcx: block,
|
pub fn trans_struct_drop(bcx: block,
|
||||||
|
t: ty::t,
|
||||||
v0: ValueRef,
|
v0: ValueRef,
|
||||||
dtor_did: ast::def_id,
|
dtor_did: ast::def_id,
|
||||||
class_did: ast::def_id,
|
class_did: ast::def_id,
|
||||||
@ -500,11 +502,12 @@ pub fn trans_struct_drop(bcx: block,
|
|||||||
Call(bcx, dtor_addr, args);
|
Call(bcx, dtor_addr, args);
|
||||||
|
|
||||||
// Drop the fields
|
// Drop the fields
|
||||||
|
let repr = adt::represent_type(bcx.ccx(), t);
|
||||||
let field_tys =
|
let field_tys =
|
||||||
ty::struct_mutable_fields(bcx.tcx(), class_did,
|
ty::struct_mutable_fields(bcx.tcx(), class_did,
|
||||||
substs);
|
substs);
|
||||||
for vec::eachi(field_tys) |i, fld| {
|
for vec::eachi(field_tys) |i, fld| {
|
||||||
let llfld_a = GEPi(bcx, v0, struct_field(i));
|
let llfld_a = adt::trans_GEP(bcx, &repr, v0, 0, i);
|
||||||
bcx = drop_ty(bcx, llfld_a, fld.mt.ty);
|
bcx = drop_ty(bcx, llfld_a, fld.mt.ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -534,10 +537,10 @@ pub fn make_drop_glue(bcx: block, v0: ValueRef, t: ty::t) {
|
|||||||
let tcx = bcx.tcx();
|
let tcx = bcx.tcx();
|
||||||
match ty::ty_dtor(tcx, did) {
|
match ty::ty_dtor(tcx, did) {
|
||||||
ty::TraitDtor(dtor) => {
|
ty::TraitDtor(dtor) => {
|
||||||
trans_struct_drop(bcx, v0, dtor, did, substs, true)
|
trans_struct_drop(bcx, t, v0, dtor, did, substs, true)
|
||||||
}
|
}
|
||||||
ty::LegacyDtor(dtor) => {
|
ty::LegacyDtor(dtor) => {
|
||||||
trans_struct_drop(bcx, v0, dtor, did, substs, false)
|
trans_struct_drop(bcx, t, v0, dtor, did, substs, false)
|
||||||
}
|
}
|
||||||
ty::NoDtor => {
|
ty::NoDtor => {
|
||||||
// No dtor? Just the default case
|
// No dtor? Just the default case
|
||||||
|
Loading…
Reference in New Issue
Block a user