Add _mutable unop.

This commit is contained in:
Graydon Hoare 2011-02-15 12:20:30 -08:00
parent 2bba49a9fe
commit 9ae89bd404
4 changed files with 14 additions and 0 deletions

View file

@ -106,6 +106,7 @@ tag unop {
bitnot;
not;
neg;
_mutable;
}
tag mode {

View file

@ -811,6 +811,13 @@ impure fn parse_prefix_expr(parser p) -> @ast.expr {
ex = ast.expr_unary(ast.box, e, ast.ann_none);
}
case (token.MUTABLE) {
p.bump();
auto e = parse_prefix_expr(p);
hi = e.span;
ex = ast.expr_unary(ast._mutable, e, ast.ann_none);
}
case (_) {
ret parse_dot_or_call_expr(p);
}

View file

@ -1834,6 +1834,9 @@ fn trans_unary(@block_ctxt cx, ast.unop op,
}
ret res(sub.bcx, val);
}
case (ast._mutable) {
ret trans_expr(cx, e);
}
}
fail;
}

View file

@ -1229,6 +1229,9 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
}
}
}
case (ast._mutable) {
oper_t = @rec(mut=ast.mut with *oper_t);
}
case (_) { oper_t = strip_boxes(oper_t); }
}
ret @fold.respan[ast.expr_](expr.span,