Skip to content

Commit 1e9c8b9

Browse files
committed
Implement translation for deref unop.
1 parent 97247bb commit 1e9c8b9

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/comp/middle/trans.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -867,8 +867,16 @@ impure fn trans_unary(@block_ctxt cx, ast.unop op,
867867
sub = copy_ty(sub.bcx, true, body, e_val, e_ty);
868868
ret res(sub.bcx, box);
869869
}
870-
case (_) {
871-
cx.fcx.ccx.sess.unimpl("expr variant in trans_unary");
870+
case (ast.deref) {
871+
sub.val = sub.bcx.build.GEP(sub.val,
872+
vec(C_int(0),
873+
C_int(abi.box_rc_field_body)));
874+
auto e_ty = node_ann_type(sub.bcx.fcx.ccx, a);
875+
if (typeck.type_is_scalar(e_ty) ||
876+
typeck.type_is_nil(e_ty)) {
877+
sub.val = sub.bcx.build.Load(sub.val);
878+
}
879+
ret sub;
872880
}
873881
}
874882
fail;

0 commit comments

Comments
 (0)