Teach the parser and typechecker to understand port[int](). Closes #588

This commit is contained in:
Eric Holk 2011-06-28 15:54:16 -07:00 committed by Brian Anderson
parent 1c6ae8cadf
commit 64596e6583
11 changed files with 85 additions and 11 deletions

View file

@ -5996,7 +5996,7 @@ fn trans_expr_out(&@block_ctxt cx, &@ast::expr e, out_method output) ->
case (ast::expr_ret(?ex)) { ret trans_ret(cx, ex); }
case (ast::expr_put(?ex)) { ret trans_put(cx, ex); }
case (ast::expr_be(?ex)) { ret trans_be(cx, ex); }
case (ast::expr_port) { ret trans_port(cx, e.id); }
case (ast::expr_port(_)) { ret trans_port(cx, e.id); }
case (ast::expr_chan(?ex)) { ret trans_chan(cx, ex, e.id); }
case (ast::expr_send(?lhs, ?rhs)) {
ret trans_send(cx, lhs, rhs, e.id);

View file

@ -556,7 +556,7 @@ fn find_pre_post_expr(&fn_ctxt fcx, @expr e) {
}
case (expr_break) { clear_pp(expr_pp(fcx.ccx, e)); }
case (expr_cont) { clear_pp(expr_pp(fcx.ccx, e)); }
case (expr_port) { clear_pp(expr_pp(fcx.ccx, e)); }
case (expr_port(_)) { clear_pp(expr_pp(fcx.ccx, e)); }
case (expr_ext(_, _, _, ?expanded)) {
find_pre_post_expr(fcx, expanded);
copy_pre_post(fcx.ccx, e.id, expanded);

View file

@ -565,7 +565,7 @@ fn find_pre_post_state_expr(&fn_ctxt fcx, &prestate pres, @expr e) -> bool {
}
case (expr_break) { ret pure_exp(fcx.ccx, e.id, pres); }
case (expr_cont) { ret pure_exp(fcx.ccx, e.id, pres); }
case (expr_port) { ret pure_exp(fcx.ccx, e.id, pres); }
case (expr_port(_)) { ret pure_exp(fcx.ccx, e.id, pres); }
case (expr_self_method(_)) { ret pure_exp(fcx.ccx, e.id, pres); }
case (expr_anon_obj(?anon_obj, _, _)) {
alt (anon_obj.with_obj) {

View file

@ -2075,8 +2075,16 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
}
}
}
case (ast::expr_port) {
case (ast::expr_port(?typ)) {
auto t = next_ty_var(fcx);
alt(typ) {
case (some(?_t)) {
demand::simple(fcx, expr.span,
ast_ty_to_ty_crate(fcx.ccx, _t),
t);
}
case (none) {}
}
auto pt = ty::mk_port(fcx.ccx.tcx, t);
write::ty_only_fixup(fcx, id, pt);
}

View file

@ -374,7 +374,7 @@ fn visit_expr[E](&@expr ex, &E e, &vt[E] v) {
case (expr_log(_, ?x)) { vt(v).visit_expr(x, e, v); }
case (expr_check(?x)) { vt(v).visit_expr(x, e, v); }
case (expr_assert(?x)) { vt(v).visit_expr(x, e, v); }
case (expr_port) { }
case (expr_port(_)) { }
case (expr_chan(?x)) { vt(v).visit_expr(x, e, v); }
case (expr_anon_obj(?anon_obj, _, _)) {
alt (anon_obj.fields) {

View file

@ -380,7 +380,7 @@ fn walk_expr(&ast_visitor v, @ast::expr e) {
case (ast::expr_log(_, ?x)) { walk_expr(v, x); }
case (ast::expr_check(?x)) { walk_expr(v, x); }
case (ast::expr_assert(?x)) { walk_expr(v, x); }
case (ast::expr_port) { }
case (ast::expr_port(_)) { }
case (ast::expr_chan(?x)) { walk_expr(v, x); }
case (ast::expr_anon_obj(?anon_obj, _, _)) {
// Fields