Make it possible to use * to dereference a resource
This commit is contained in:
parent
b3443eb049
commit
d730bb730a
3 changed files with 16 additions and 9 deletions
|
|
@ -544,10 +544,14 @@ fn expr_root(&ctx cx, @ast::expr ex, bool autoderef) ->
|
|||
auto base_t = ty::expr_ty(*cx.tcx, base);
|
||||
alt (ty::struct(*cx.tcx, base_t)) {
|
||||
case (ty::ty_box(?mt)) {
|
||||
vec::push(ds,
|
||||
rec(mut=mt.mut != ast::imm,
|
||||
kind=unbox,
|
||||
outer_t=base_t));
|
||||
vec::push(ds, rec(mut=mt.mut != ast::imm,
|
||||
kind=unbox,
|
||||
outer_t=base_t));
|
||||
}
|
||||
case (ty::ty_res(_, ?inner)) {
|
||||
vec::push(ds, rec(mut=false,
|
||||
kind=unbox,
|
||||
outer_t=base_t));
|
||||
}
|
||||
}
|
||||
ex = base;
|
||||
|
|
|
|||
|
|
@ -4511,8 +4511,7 @@ fn trans_for_each(&@block_ctxt cx, &@ast::local local, &@ast::expr seq,
|
|||
cx.build.Store(llenvblobptr, env_cell);
|
||||
// log "lliterbody: " + val_str(lcx.ccx.tn, lliterbody);
|
||||
|
||||
r =
|
||||
trans_call(cx, f, some[ValueRef](cx.build.Load(pair)), args,
|
||||
r = trans_call(cx, f, some[ValueRef](cx.build.Load(pair)), args,
|
||||
seq.id);
|
||||
ret rslt(r.bcx, C_nil());
|
||||
}
|
||||
|
|
@ -4993,9 +4992,12 @@ fn trans_lval(&@block_ctxt cx, &@ast::expr e) -> lval_result {
|
|||
case (ast::expr_unary(?unop, ?base)) {
|
||||
assert (unop == ast::deref);
|
||||
auto sub = trans_expr(cx, base);
|
||||
auto val =
|
||||
sub.bcx.build.GEP(sub.val,
|
||||
[C_int(0), C_int(abi::box_rc_field_body)]);
|
||||
auto t = ty::expr_ty(cx.fcx.lcx.ccx.tcx, base);
|
||||
auto offset = alt (ty::struct(cx.fcx.lcx.ccx.tcx, t)) {
|
||||
case (ty::ty_box(_)) { abi::box_rc_field_body }
|
||||
case (ty::ty_res(_, _)) { 1 }
|
||||
};
|
||||
auto val = sub.bcx.build.GEP(sub.val, [C_int(0), C_int(offset)]);
|
||||
ret lval_mem(sub.bcx, val);
|
||||
}
|
||||
case (ast::expr_self_method(?ident)) {
|
||||
|
|
|
|||
|
|
@ -1526,6 +1526,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
|
|||
case (ast::deref) {
|
||||
alt (structure_of(fcx, expr.span, oper_t)) {
|
||||
case (ty::ty_box(?inner)) { oper_t = inner.ty; }
|
||||
case (ty::ty_res(_, ?inner)) { oper_t = inner; }
|
||||
case (_) {
|
||||
auto s = "dereferencing non-box type: " +
|
||||
ty_to_str(fcx.ccx.tcx, oper_t);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue