Parse and typecheck by-value and by-ref arg specs

Add sprinkle && throughout the compiler to make it typecheck again.

Issue #1008
This commit is contained in:
Marijn Haverbeke 2011-10-06 12:26:12 +02:00
parent 4709038d64
commit f9fbd86f52
32 changed files with 230 additions and 197 deletions

View file

@ -587,17 +587,11 @@ fn parse_ty(p: parser, colons_before_params: bool) -> @ast::ty {
}
fn parse_arg_mode(p: parser) -> ast::mode {
if eat(p, token::BINOP(token::AND)) {
ret ast::by_mut_ref;
} else if eat(p, token::BINOP(token::MINUS)) {
ret ast::by_move;
} else {
// FIXME Temporarily ignore these, to make it possible to implement
// them without breaking the stage0 build.
eat(p, token::ANDAND);
eat(p, token::BINOP(token::PLUS));
ret ast::by_ref;
}
if eat(p, token::BINOP(token::AND)) { ast::by_mut_ref }
else if eat(p, token::BINOP(token::MINUS)) { ast::by_move }
else if eat(p, token::ANDAND) { ast::by_ref }
else if eat(p, token::BINOP(token::PLUS)) { ast::by_val }
else { ast::mode_infer }
}
fn parse_arg(p: parser) -> ast::arg {
@ -1890,7 +1884,8 @@ fn parse_item_res(p: parser, attrs: [ast::attribute]) -> @ast::item {
let dtor = parse_block_no_value(p);
let decl =
{inputs:
[{mode: ast::by_ref, ty: t, ident: arg_ident, id: p.get_id()}],
[{mode: ast::by_ref, ty: t, ident: arg_ident,
id: p.get_id()}],
output: @spanned(lo, lo, ast::ty_nil),
purity: ast::impure_fn,
il: ast::il_normal,