Rename ast::controlflow to ast::ret_style

It will include information about returning by alias.
This commit is contained in:
Marijn Haverbeke 2011-09-14 10:38:23 +02:00
parent f6fe07d1f3
commit 6eb9738a66
13 changed files with 58 additions and 61 deletions

View file

@ -261,7 +261,7 @@ type ty_method_ =
ident: ident,
inputs: [ty_arg],
output: @ty,
cf: controlflow,
cf: ret_style,
constrs: [@constr]};
type ty_field = spanned<ty_field_>;
@ -311,7 +311,7 @@ tag ty_ {
ty_port(@ty);
ty_chan(@ty);
ty_rec([ty_field]);
ty_fn(proto, [ty_arg], @ty, controlflow, [@constr]);
ty_fn(proto, [ty_arg], @ty, ret_style, [@constr]);
ty_obj([ty_method]);
ty_tup([@ty]);
ty_path(path, node_id);
@ -369,7 +369,7 @@ type fn_decl =
output: @ty,
purity: purity,
il: inlineness,
cf: controlflow,
cf: ret_style,
constraints: [@constr]};
tag purity {
@ -377,14 +377,11 @@ tag purity {
impure_fn; // declared with "fn"
}
tag controlflow {
tag ret_style {
noreturn; // functions with return type _|_ that always
// raise an error or exit (i.e. never return to the caller)
return; // everything else
return_val; // everything else
return_alias;
}
type _fn = {decl: fn_decl, proto: proto, body: blk};

View file

@ -289,10 +289,10 @@ fn parse_ty_fn(proto: ast::proto, p: parser) -> ast::ty_ {
// auto constrs = parse_constrs(~[], p);
let constrs: [@ast::constr] = [];
let output: @ast::ty;
let cf = ast::return;
let cf = ast::return_val;
if p.peek() == token::RARROW {
p.bump();
let tmp = parse_ty_or_bang(p);
let tmp = parse_ret_ty(p);
alt tmp {
a_ty(t) { output = t; }
a_bang. {
@ -452,7 +452,12 @@ fn parse_ty_postfix(orig_t: ast::ty_, p: parser, colons_before_params: bool)
}
}
fn parse_ty_or_bang(p: parser) -> ty_or_bang {
fn parse_ret_ty(p: parser) -> ty_or_bang {
/* if eat(p, token::RARROW) {
} else {
}*/
alt p.peek() {
token::NOT. { p.bump(); ret a_bang; }
_ { ret a_ty(parse_ty(p, false)); }
@ -1766,7 +1771,7 @@ fn parse_fn_decl(p: parser, purity: ast::purity, il: ast::inlineness) ->
}
if p.peek() == token::RARROW {
p.bump();
rslt = parse_ty_or_bang(p);
rslt = parse_ret_ty(p);
} else {
rslt = a_ty(@spanned(inputs.span.lo, inputs.span.hi, ast::ty_nil));
}
@ -1776,7 +1781,7 @@ fn parse_fn_decl(p: parser, purity: ast::purity, il: ast::inlineness) ->
output: t,
purity: purity,
il: il,
cf: ast::return,
cf: ast::return_val,
constraints: constrs};
}
a_bang. {
@ -1803,7 +1808,7 @@ fn parse_fn_block_decl(p: parser) -> ast::fn_decl {
output: @spanned(p.get_lo_pos(), p.get_hi_pos(), ast::ty_infer),
purity: ast::impure_fn,
il: ast::il_normal,
cf: ast::return,
cf: ast::return_val,
constraints: []};
}
@ -1899,7 +1904,7 @@ fn parse_item_res(p: parser, attrs: [ast::attribute]) -> @ast::item {
output: @spanned(lo, lo, ast::ty_nil),
purity: ast::impure_fn,
il: ast::il_normal,
cf: ast::return,
cf: ast::return_val,
constraints: []};
let f = {decl: decl, proto: ast::proto_fn, body: dtor};
ret mk_item(p, lo, dtor.span.hi, ident,

View file

@ -1401,7 +1401,7 @@ fn print_mt(s: ps, mt: ast::mt) {
}
fn print_ty_fn(s: ps, proto: ast::proto, id: option::t<ast::ident>,
inputs: [ast::ty_arg], output: @ast::ty, cf: ast::controlflow,
inputs: [ast::ty_arg], output: @ast::ty, cf: ast::ret_style,
constrs: [@ast::constr]) {
ibox(s, indent_unit);
word(s.s, proto_to_str(proto));
@ -1420,7 +1420,7 @@ fn print_ty_fn(s: ps, proto: ast::proto, id: option::t<ast::ident>,
ibox(s, indent_unit);
word_space(s, "->");
alt cf {
ast::return. { print_type(s, output); }
ast::return_val. { print_type(s, output); }
ast::noreturn. { word_nbsp(s, "!"); }
}
end(s);