rustc: Make functions output a type, not a slot

This commit is contained in:
Patrick Walton 2010-10-08 12:26:34 -07:00
parent 785d9b1594
commit e3758fe321
3 changed files with 8 additions and 9 deletions

View File

@ -129,7 +129,7 @@ type slot = rec(@ty ty, mode mode, option[slot_id] id);
type input = rec(slot slot, ident ident);
type _fn = rec(vec[input] inputs,
slot output,
ty output,
block body);
type _mod = hashmap[ident,@item];

View File

@ -603,13 +603,12 @@ io fn parse_fn(parser p) -> tup(ast.ident, @ast.item) {
some(token.COMMA),
pf, p);
let ast.slot output;
let ast.ty output;
if (p.peek() == token.RARROW) {
p.bump();
output = rec(ty=parse_ty(p), mode=ast.val, id=none[ast.slot_id]);
output = *parse_ty(p);
} else {
output = rec(ty=@spanned(lo, inputs.span, ast.ty_nil),
mode=ast.val, id=none[ast.slot_id]);
output = spanned(lo, inputs.span, ast.ty_nil);
}
auto body = parse_block(p);

View File

@ -120,7 +120,7 @@ type ast_fold[ENV] =
vec[@stmt] stmts) -> block) fold_block,
(fn(&ENV e, vec[ast.input] inputs,
&slot output, block body) -> ast._fn) fold_fn,
&ty output, block body) -> ast._fn) fold_fn,
(fn(&ENV e, &ast._mod m) -> ast._mod) fold_mod,
@ -310,10 +310,10 @@ fn fold_fn[ENV](&ENV env, ast_fold[ENV] fld, &ast._fn f) -> ast._fn {
let operator[ast.input,ast.input] fi = bind fold_input[ENV](env, fld, _);
auto inputs = _vec.map[ast.input, ast.input](fi, f.inputs);
auto output = fold_slot[ENV](env, fld, f.output);
auto output = fold_ty[ENV](env, fld, @f.output);
auto body = fold_block[ENV](env, fld, f.body);
ret fld.fold_fn(env, inputs, output, body);
ret fld.fold_fn(env, inputs, *output, body);
}
fn fold_item[ENV](&ENV env, ast_fold[ENV] fld, @item i) -> @item {
@ -539,7 +539,7 @@ fn identity_fold_block[ENV](&ENV e, &span sp, vec[@stmt] stmts) -> block {
fn identity_fold_fn[ENV](&ENV e,
vec[ast.input] inputs,
&slot output,
&ast.ty output,
block body) -> ast._fn {
ret rec(inputs=inputs, output=output, body=body);
}