Skip to content

Commit 383a51b

Browse files
committed
---
yaml --- r: 4186 b: refs/heads/master c: ab8d91d h: refs/heads/master v: v3
1 parent 46ff71b commit 383a51b

File tree

2 files changed

+12
-22
lines changed

2 files changed

+12
-22
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 73e8e49897c2a92d5908e89f392bd40386219aab
2+
refs/heads/master: ab8d91dcfd051db703b09fbbcd3a67f2536d6a0f

trunk/src/comp/middle/trans.rs

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4350,7 +4350,7 @@ fn trans_cast(cx: &@block_ctxt, e: &@ast::expr, id: ast::node_id) -> result {
43504350
fn trans_bind_thunk(cx: &@local_ctxt, sp: &span, incoming_fty: &ty::t,
43514351
outgoing_fty: &ty::t, args: &(option::t[@ast::expr])[],
43524352
closure_ty: &ty::t, bound_tys: &ty::t[],
4353-
ty_param_count: uint) -> ValueRef {
4353+
ty_param_count: uint) -> {val: ValueRef, ty: TypeRef} {
43544354

43554355
// Here we're not necessarily constructing a thunk in the sense of
43564356
// "function with no arguments". The result of compiling 'bind f(foo,
@@ -4520,7 +4520,7 @@ fn trans_bind_thunk(cx: &@local_ctxt, sp: &span, incoming_fty: &ty::t,
45204520
bcx.build.FastCall(lltargetfn, llargs);
45214521
bcx.build.RetVoid();
45224522
finish_fn(fcx, lltop);
4523-
ret llthunk;
4523+
ret {val: llthunk, ty: llthunk_ty};
45244524
}
45254525

45264526
fn trans_bind(cx: &@block_ctxt, f: &@ast::expr,
@@ -4552,15 +4552,13 @@ fn trans_bind_1(cx: &@block_ctxt, f: &@ast::expr, f_res: &lval_result,
45524552
lltydescs = ginfo.tydescs;
45534553
}
45544554
}
4555-
let ty_param_count = std::ivec::len[ValueRef](lltydescs);
4556-
if std::ivec::len[@ast::expr](bound) == 0u && ty_param_count == 0u {
45574555

4556+
let ty_param_count = std::ivec::len(lltydescs);
4557+
if std::ivec::len(bound) == 0u && ty_param_count == 0u {
45584558
// Trivial 'binding': just return the static pair-ptr.
45594559
ret f_res.res;
45604560
}
45614561
let bcx = f_res.res.bcx;
4562-
let pair_t = node_type(bcx_ccx(cx), cx.sp, id);
4563-
let pair_v = alloca(bcx, pair_t);
45644562

45654563
// Translate the bound expressions.
45664564
let bound_tys: ty::t[] = ~[];
@@ -4675,23 +4673,15 @@ fn trans_bind_1(cx: &@block_ctxt, f: &@ast::expr, f_res: &lval_result,
46754673
}
46764674
}
46774675

4678-
// Make thunk and store thunk-ptr in outer pair's code slot.
4679-
let pair_code =
4680-
bcx.build.GEP(pair_v, ~[C_int(0), C_int(abi::fn_field_code)]);
4676+
// Make thunk
46814677
// The type of the entire bind expression.
4682-
let pair_ty: ty::t = node_id_type(bcx_ccx(cx), id);
4678+
let pair_ty = node_id_type(bcx_ccx(cx), id);
4679+
let llthunk =
4680+
trans_bind_thunk(cx.fcx.lcx, cx.sp, pair_ty, outgoing_fty,
4681+
args, closure_ty, bound_tys, ty_param_count);
46834682

4684-
let llthunk: ValueRef =
4685-
trans_bind_thunk(cx.fcx.lcx, cx.sp, pair_ty, outgoing_fty, args,
4686-
closure_ty, bound_tys, ty_param_count);
4687-
bcx.build.Store(llthunk, pair_code);
4688-
4689-
// Store box ptr in outer pair's box slot.
4690-
let ccx = *bcx_ccx(bcx);
4691-
let pair_box =
4692-
bcx.build.GEP(pair_v, ~[C_int(0), C_int(abi::fn_field_box)]);
4693-
bcx.build.Store(bcx.build.PointerCast(box, T_opaque_closure_ptr(ccx)),
4694-
pair_box);
4683+
// Construct the function pair
4684+
let pair_v = create_real_fn_pair(bcx, llthunk.ty, llthunk.val, box);
46954685
add_clean_temp(cx, pair_v, pair_ty);
46964686
ret rslt(bcx, pair_v);
46974687
}

0 commit comments

Comments
 (0)