Change the interface of placement new to take a tydesc as part of Issue #2831.
This commit is contained in:
@@ -3693,9 +3693,9 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block {
|
||||
ret trans_assign_op(bcx, e, op, dst, src);
|
||||
}
|
||||
ast::expr_new(pool, alloc_id, val) {
|
||||
// First, call pool->alloc(sz, align) to get back a void*. Then,
|
||||
// cast this memory to the required type and evaluate value into
|
||||
// it.
|
||||
// First, call pool->alloc(tydesc) to get back a void*.
|
||||
// Then, cast this memory to the required type and evaluate value
|
||||
// into it.
|
||||
let ccx = bcx.ccx();
|
||||
|
||||
// Allocate space for the ptr that will be returned from
|
||||
@@ -3706,24 +3706,21 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block {
|
||||
#debug["ptr_ty = %s", ppaux::ty_to_str(tcx, ptr_ty)];
|
||||
#debug["ptr_ptr_val = %s", val_str(ccx.tn, ptr_ptr_val)];
|
||||
|
||||
let void_ty = ty::mk_ptr(tcx, {ty: ty::mk_nil(tcx),
|
||||
mutbl: ast::m_imm});
|
||||
let voidval = {
|
||||
let llvoid_ty = type_of(ccx, void_ty);
|
||||
PointerCast(bcx, ptr_ptr_val, T_ptr(llvoid_ty))
|
||||
};
|
||||
|
||||
let void_ty = ty::mk_nil_ptr(tcx);
|
||||
let llvoid_ty = type_of(ccx, void_ty);
|
||||
let voidval = PointerCast(bcx, ptr_ptr_val, T_ptr(llvoid_ty));
|
||||
#debug["voidval = %s", val_str(ccx.tn, voidval)];
|
||||
|
||||
let llval_ty = type_of(ccx, expr_ty(bcx, val));
|
||||
let args =
|
||||
~[llsize_of(ccx, llval_ty), llalign_of(ccx, llval_ty)];
|
||||
let static_ti = get_tydesc(ccx, expr_ty(bcx, val));
|
||||
lazily_emit_all_tydesc_glue(ccx, static_ti);
|
||||
let lltydesc = PointerCast(bcx, static_ti.tydesc, llvoid_ty);
|
||||
|
||||
let origin = bcx.ccx().maps.method_map.get(alloc_id);
|
||||
let bcx = trans_call_inner(
|
||||
bcx, e.info(), node_id_type(bcx, alloc_id), void_ty,
|
||||
|bcx| impl::trans_method_callee(bcx, alloc_id,
|
||||
pool, origin),
|
||||
arg_vals(args),
|
||||
arg_vals(~[lltydesc]),
|
||||
save_in(voidval));
|
||||
|
||||
#debug["dest = %s", dest_str(ccx, dest)];
|
||||
|
||||
@@ -1631,17 +1631,15 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
||||
some(entry) {
|
||||
fcx.ccx.method_map.insert(alloc_id, entry);
|
||||
|
||||
// Check that the alloc() method has the expected type, which
|
||||
// should be fn(sz: uint, align: uint) -> *().
|
||||
// Check that the alloc() method has the expected
|
||||
// type, which should be fn(tydesc: *()) -> *().
|
||||
let expected_ty = {
|
||||
let ty_uint = ty::mk_uint(tcx);
|
||||
let ty_nilp = ty::mk_ptr(tcx, {ty: ty::mk_nil(tcx),
|
||||
mutbl: ast::m_imm});
|
||||
let m = ast::expl(ty::default_arg_mode_for_ty(ty_uint));
|
||||
let m = ast::expl(ty::default_arg_mode_for_ty(ty_nilp));
|
||||
ty::mk_fn(tcx, {purity: ast::impure_fn,
|
||||
proto: ast::proto_any,
|
||||
inputs: ~[{mode: m, ty: ty_uint},
|
||||
{mode: m, ty: ty_uint}],
|
||||
inputs: ~[{mode: m, ty: ty_nilp}],
|
||||
output: ty_nilp,
|
||||
ret_style: ast::return_val,
|
||||
constraints: ~[]})
|
||||
|
||||
Reference in New Issue
Block a user