diff options
| author | Brian Anderson <[email protected]> | 2011-03-21 21:13:08 -0400 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2011-03-22 08:04:45 -0700 |
| commit | c02cdc32a82c37e887add86773cbf49e446b335f (patch) | |
| tree | 89f8a94c689fbc3a1aa33b4ea55472f1efd88cf4 /src/comp | |
| parent | Un-XFAIL task-comm-4, 5 & 6 (diff) | |
| download | rust-c02cdc32a82c37e887add86773cbf49e446b335f.tar.xz rust-c02cdc32a82c37e887add86773cbf49e446b335f.zip | |
Generalize send/recv to work for more types
Diffstat (limited to 'src/comp')
| -rw-r--r-- | src/comp/middle/trans.rs | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index aac7dce2..a95ebcab 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -4790,17 +4790,19 @@ fn trans_send(@block_ctxt cx, @ast.expr lhs, @ast.expr rhs, } } - auto llunit_ty = type_of(bcx.fcx.ccx, unit_ty); - auto data_alloca = bcx.build.Alloca(llunit_ty); - bcx.build.Store(data.val, data_alloca); + auto data_alloc = alloc_ty(bcx, unit_ty); + bcx = data_alloc.bcx; + auto data_tmp = copy_ty(bcx, INIT, data_alloc.val, data.val, unit_ty); + bcx = data_tmp.bcx; - auto chn_val = vp2i(bcx, chn.val); - auto data_val = vp2i(bcx, data_alloca); + // TODO: Cleanups? - auto sub = trans_upcall(bcx, "upcall_send", vec(chn_val, data_val)); + auto sub = trans_upcall(bcx, "upcall_send", + vec(vp2i(bcx, chn.val), + vp2i(bcx, data_alloc.val))); bcx = sub.bcx; - ret res(bcx, chn_val); + ret res(bcx, chn.val); } fn trans_recv(@block_ctxt cx, @ast.expr lhs, @ast.expr rhs, @@ -4813,17 +4815,19 @@ fn trans_recv(@block_ctxt cx, @ast.expr lhs, @ast.expr rhs, auto prt = trans_expr(bcx, rhs); bcx = prt.bcx; + auto sub = trans_upcall(bcx, "upcall_recv", + vec(vp2i(bcx, data.res.val), + vp2i(bcx, prt.val))); + bcx = sub.bcx; + auto unit_ty = node_ann_type(cx.fcx.ccx, ann); - auto llunit_ty = type_of(bcx.fcx.ccx, unit_ty); - auto data_alloca = bcx.build.Alloca(llunit_ty); + auto data_load = load_scalar_or_boxed(bcx, data.res.val, unit_ty); + auto cp = copy_ty(bcx, DROP_EXISTING, data.res.val, data_load, unit_ty); + bcx = cp.bcx; - auto data_val = vp2i(bcx, data_alloca); - auto prt_val = vp2i(bcx, prt.val); - auto sub = trans_upcall(bcx, "upcall_recv", vec(data_val, prt_val)); - bcx = sub.bcx; + // TODO: Cleanups? - auto data_load = bcx.build.Load(data_alloca); - ret copy_ty(bcx, DROP_EXISTING, data.res.val, data_load, unit_ty); + ret res(bcx, data.res.val); } fn init_local(@block_ctxt cx, @ast.local local) -> result { |