about summary refs log tree commit diff
path: root/src/comp/syntax
diff options
context:
space:
mode:
authorMarijn Haverbeke <marijnh@gmail.com>2011-09-14 10:38:23 +0200
committerMarijn Haverbeke <marijnh@gmail.com>2011-09-14 10:38:23 +0200
commit6eb9738a661f577eeb972032b5570013e6bcafdd (patch)
tree526faf2c5e590605d2d796371c75a9e98c35f1ef /src/comp/syntax
parentf6fe07d1f3f8e98120169dea59ebc4d2eee4255c (diff)
downloadrust-6eb9738a661f577eeb972032b5570013e6bcafdd.tar.gz
rust-6eb9738a661f577eeb972032b5570013e6bcafdd.zip
Rename ast::controlflow to ast::ret_style
It will include information about returning by alias.
Diffstat (limited to 'src/comp/syntax')
-rw-r--r--src/comp/syntax/ast.rs15
-rw-r--r--src/comp/syntax/parse/parser.rs19
-rw-r--r--src/comp/syntax/print/pprust.rs4
3 files changed, 20 insertions, 18 deletions
diff --git a/src/comp/syntax/ast.rs b/src/comp/syntax/ast.rs
index 6032ea11dbc..0db696654be 100644
--- a/src/comp/syntax/ast.rs
+++ b/src/comp/syntax/ast.rs
@@ -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};
diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs
index 5006277ec6b..e6679f60b17 100644
--- a/src/comp/syntax/parse/parser.rs
+++ b/src/comp/syntax/parse/parser.rs
@@ -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,
diff --git a/src/comp/syntax/print/pprust.rs b/src/comp/syntax/print/pprust.rs
index f401d4e3736..4230beab7db 100644
--- a/src/comp/syntax/print/pprust.rs
+++ b/src/comp/syntax/print/pprust.rs
@@ -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);