Represent unique creation as a unop in the AST instead of its own expr
Like the box unop. Issue #409
This commit is contained in:
parent
7ae251789c
commit
f809e22697
@ -2183,6 +2183,9 @@ fn trans_unary(cx: @block_ctxt, op: ast::unop, e: @ast::expr,
|
||||
let bcx = move_val_if_temp(sub.bcx, INIT, body, lv, e_ty);
|
||||
ret rslt(bcx, sub.box);
|
||||
}
|
||||
ast::uniq(_) {
|
||||
ret trans_uniq(cx, e, id);
|
||||
}
|
||||
ast::deref. {
|
||||
bcx_ccx(cx).sess.bug("deref expressions should have been \
|
||||
translated using trans_lval(), not \
|
||||
@ -4246,9 +4249,6 @@ fn trans_expr_out(cx: @block_ctxt, e: @ast::expr, output: out_method) ->
|
||||
CondBr(cx, cond, then_cx.llbb, else_cx.llbb);
|
||||
ret rslt(join_branches(cx, [check_res, els]), C_nil());
|
||||
}
|
||||
ast::expr_uniq(contents) {
|
||||
ret trans_uniq(cx, contents, e.id);
|
||||
}
|
||||
ast::expr_break. { ret trans_break(e.span, cx); }
|
||||
ast::expr_cont. { ret trans_cont(e.span, cx); }
|
||||
ast::expr_ret(ex) { ret trans_ret(cx, ex); }
|
||||
|
@ -559,7 +559,6 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) {
|
||||
none. { clear_pp(expr_pp(fcx.ccx, e)); }
|
||||
}
|
||||
}
|
||||
expr_uniq(sub) { find_pre_post_exprs(fcx, [sub], e.id); }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -608,7 +608,6 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
|
||||
none. { ret pure_exp(fcx.ccx, e.id, pres); }
|
||||
}
|
||||
}
|
||||
expr_uniq(_) { ret pure_exp(fcx.ccx, e.id, pres); }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1719,6 +1719,9 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
|
||||
let oper_t = expr_ty(tcx, oper);
|
||||
alt unop {
|
||||
ast::box(mut) { oper_t = ty::mk_box(tcx, {ty: oper_t, mut: mut}); }
|
||||
ast::uniq(mut) {
|
||||
oper_t = ty::mk_uniq(tcx, oper_t);
|
||||
}
|
||||
ast::deref. {
|
||||
alt structure_of(fcx, expr.span, oper_t) {
|
||||
ty::ty_box(inner) { oper_t = inner.ty; }
|
||||
@ -2349,11 +2352,6 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
|
||||
// Now remove the info from the stack.
|
||||
vec::pop::<obj_info>(fcx.ccx.obj_infos);
|
||||
}
|
||||
ast::expr_uniq(x) {
|
||||
let t = next_ty_var(fcx);
|
||||
check_expr_with(fcx, x, t);
|
||||
write::ty_only_fixup(fcx, id, ty::mk_uniq(tcx, t));
|
||||
}
|
||||
_ { tcx.sess.unimpl("expr type in typeck::check_expr"); }
|
||||
}
|
||||
if bot { write::ty_only_fixup(fcx, expr.id, ty::mk_bot(tcx)); }
|
||||
|
@ -124,7 +124,11 @@ tag binop {
|
||||
gt;
|
||||
}
|
||||
|
||||
tag unop { box(mutability); deref; not; neg; }
|
||||
tag unop {
|
||||
box(mutability);
|
||||
uniq(mutability);
|
||||
deref; not; neg;
|
||||
}
|
||||
|
||||
tag mode { by_ref; by_mut_ref; by_move; }
|
||||
|
||||
@ -215,7 +219,6 @@ tag expr_ {
|
||||
expr_if_check(@expr, blk, option::t<@expr>);
|
||||
expr_anon_obj(anon_obj);
|
||||
expr_mac(mac);
|
||||
expr_uniq(@expr);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -110,6 +110,7 @@ pure fn lazy_binop(b: binop) -> bool {
|
||||
fn unop_to_str(op: unop) -> str {
|
||||
alt op {
|
||||
box(mt) { if mt == mut { ret "@mutable "; } ret "@"; }
|
||||
uniq(mt) { if mt == mut { ret "~mutable "; } ret "~"; }
|
||||
deref. { ret "*"; }
|
||||
not. { ret "!"; }
|
||||
neg. { ret "-"; }
|
||||
|
@ -424,7 +424,6 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ {
|
||||
}
|
||||
expr_anon_obj(ao) { expr_anon_obj(fold_anon_obj(ao)) }
|
||||
expr_mac(mac) { expr_mac(fold_mac(mac)) }
|
||||
expr_uniq(e) { expr_uniq(fld.fold_expr(e)) }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -886,9 +886,6 @@ fn parse_bottom_expr(p: parser) -> @ast::expr {
|
||||
} else if p.peek() == token::ELLIPSIS {
|
||||
p.bump();
|
||||
ret mk_mac_expr(p, lo, p.get_hi_pos(), ast::mac_ellipsis);
|
||||
} else if p.peek() == token::TILDE {
|
||||
p.bump();
|
||||
ex = ast::expr_uniq(parse_expr(p));
|
||||
} else if eat_word(p, "obj") {
|
||||
// Anonymous object
|
||||
|
||||
@ -1145,6 +1142,13 @@ fn parse_prefix_expr(p: parser) -> @ast::expr {
|
||||
hi = e.span.hi;
|
||||
ex = ast::expr_unary(ast::box(m), e);
|
||||
}
|
||||
token::TILDE. {
|
||||
p.bump();
|
||||
let m = parse_mutability(p);
|
||||
let e = parse_prefix_expr(p);
|
||||
hi = e.span.hi;
|
||||
ex = ast::expr_unary(ast::uniq(m), e);
|
||||
}
|
||||
_ { ret parse_dot_or_call_expr(p); }
|
||||
}
|
||||
ret mk_expr(p, lo, hi, ex);
|
||||
|
@ -988,7 +988,6 @@ fn print_expr(s: ps, expr: @ast::expr) {
|
||||
}
|
||||
bclose(s, expr.span);
|
||||
}
|
||||
ast::expr_uniq(expr) { word(s.s, "~"); print_expr(s, expr); }
|
||||
}
|
||||
s.ann.post(ann_node);
|
||||
end(s);
|
||||
@ -1001,7 +1000,7 @@ fn print_expr_parens_if_not_bot(s: ps, ex: @ast::expr) {
|
||||
ast::expr_ternary(_, _, _) | ast::expr_move(_, _) |
|
||||
ast::expr_copy(_) | ast::expr_assign(_, _) | ast::expr_be(_) |
|
||||
ast::expr_assign_op(_, _, _) | ast::expr_swap(_, _) |
|
||||
ast::expr_log(_, _) | ast::expr_assert(_) | ast::expr_uniq(_) |
|
||||
ast::expr_log(_, _) | ast::expr_assert(_) |
|
||||
ast::expr_check(_, _) { true }
|
||||
_ { false }
|
||||
};
|
||||
@ -1658,7 +1657,7 @@ fn ends_in_lit_int(ex: @ast::expr) -> bool {
|
||||
ast::expr_ternary(_, _, sub) | ast::expr_move(_, sub) |
|
||||
ast::expr_copy(sub) | ast::expr_assign(_, sub) | ast::expr_be(sub) |
|
||||
ast::expr_assign_op(_, _, sub) | ast::expr_swap(_, sub) |
|
||||
ast::expr_log(_, sub) | ast::expr_assert(sub) | ast::expr_uniq(sub) |
|
||||
ast::expr_log(_, sub) | ast::expr_assert(sub) |
|
||||
ast::expr_check(_, sub) { ends_in_lit_int(sub) }
|
||||
ast::expr_fail(osub) | ast::expr_ret(osub) | ast::expr_put(osub) {
|
||||
alt osub {
|
||||
|
@ -325,7 +325,6 @@ fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) {
|
||||
}
|
||||
}
|
||||
expr_mac(mac) { visit_mac(mac, e, v); }
|
||||
expr_uniq(x) { v.visit_expr(x, e, v); }
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user