about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMarijn Haverbeke <marijnh@gmail.com>2011-12-23 13:32:17 +0100
committerMarijn Haverbeke <marijnh@gmail.com>2011-12-23 13:32:17 +0100
commit970f5cc0e422a959aa6df9a2e3a545203b271cc8 (patch)
treeba362618ed52ceb0beed04d266b19742c7e88e0f
parentf0dfbe7b1b8d630488441982cf3d46f82a3a89db (diff)
downloadrust-970f5cc0e422a959aa6df9a2e3a545203b271cc8.tar.gz
rust-970f5cc0e422a959aa6df9a2e3a545203b271cc8.zip
Make ast::ty_method hold a fn_decl, rather than duplicating its fields
-rw-r--r--src/comp/middle/typeck.rs12
-rw-r--r--src/comp/syntax/ast.rs10
-rw-r--r--src/comp/syntax/parse/parser.rs9
-rw-r--r--src/comp/syntax/print/pprust.rs24
-rw-r--r--src/comp/syntax/visit.rs4
5 files changed, 20 insertions, 39 deletions
diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs
index c11f9ef6568..2997994b0a4 100644
--- a/src/comp/middle/typeck.rs
+++ b/src/comp/middle/typeck.rs
@@ -356,21 +356,21 @@ fn ast_ty_to_ty(tcx: ty::ctxt, mode: mode, &&ast_ty: @ast::ty) -> ty::t {
         let tmeths: [ty::method] = [];
         for m: ast::ty_method in meths {
             let ins = [];
-            for ta: ast::arg in m.node.inputs {
+            for ta: ast::arg in m.decl.inputs {
                 ins += [ast_arg_to_arg(tcx, mode, ta)];
             }
-            let out = ast_ty_to_ty(tcx, mode, m.node.output);
+            let out = ast_ty_to_ty(tcx, mode, m.decl.output);
 
             let out_constrs = [];
-            for constr: @ast::constr in m.node.constrs {
+            for constr: @ast::constr in m.decl.constraints {
                 out_constrs += [ty::ast_constr_to_constr(tcx, constr)];
             }
             let new_m: ty::method =
-                {proto: m.node.proto,
-                 ident: m.node.ident,
+                {proto: m.decl.proto,
+                 ident: m.ident,
                  inputs: ins,
                  output: out,
-                 cf: m.node.cf,
+                 cf: m.decl.cf,
                  constrs: out_constrs};
             tmeths += [new_m];
         }
diff --git a/src/comp/syntax/ast.rs b/src/comp/syntax/ast.rs
index 98dfb74ea70..a94e860b764 100644
--- a/src/comp/syntax/ast.rs
+++ b/src/comp/syntax/ast.rs
@@ -307,17 +307,9 @@ type mt = {ty: @ty, mut: mutability};
 
 type ty_field_ = {ident: ident, mt: mt};
 
-type ty_method_ =
-    {proto: proto,
-     ident: ident,
-     inputs: [arg],
-     output: @ty,
-     cf: ret_style,
-     constrs: [@constr]};
-
 type ty_field = spanned<ty_field_>;
 
-type ty_method = spanned<ty_method_>;
+type ty_method = {ident: ident, decl: fn_decl, span: span};
 
 tag int_ty { ty_i; ty_char; ty_i8; ty_i16; ty_i32; ty_i64; }
 
diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs
index 3f2c11dd821..484659f4bc5 100644
--- a/src/comp/syntax/parse/parser.rs
+++ b/src/comp/syntax/parse/parser.rs
@@ -294,14 +294,7 @@ fn parse_ty_obj(p: parser) -> ast::ty_ {
         expect(p, token::SEMI);
         alt f {
           ast::ty_fn(d) {
-            // FIXME[fn_decl]
-            ret spanned(flo, fhi,
-                        {proto: d.proto,
-                         ident: ident,
-                         inputs: d.inputs,
-                         output: d.output,
-                         cf: d.cf,
-                         constrs: d.constraints});
+            {ident: ident, decl: d, span: ast_util::mk_sp(flo, fhi)}
           }
         }
     }
diff --git a/src/comp/syntax/print/pprust.rs b/src/comp/syntax/print/pprust.rs
index ac032ffa76a..e2856c60f8d 100644
--- a/src/comp/syntax/print/pprust.rs
+++ b/src/comp/syntax/print/pprust.rs
@@ -306,8 +306,7 @@ fn print_type(s: ps, &&ty: @ast::ty) {
         pclose(s);
       }
       ast::ty_fn(d) {
-        print_ty_fn(s, d.proto, none::<str>, d.inputs, d.output, d.cf,
-                    d.constraints);
+        print_ty_fn(s, d, none::<str>);
       }
       ast::ty_obj(methods) {
         head(s, "obj");
@@ -316,8 +315,7 @@ fn print_type(s: ps, &&ty: @ast::ty) {
             hardbreak_if_not_bol(s);
             cbox(s, indent_unit);
             maybe_print_comment(s, m.span.lo);
-            print_ty_fn(s, m.node.proto, some(m.node.ident), m.node.inputs,
-                        m.node.output, m.node.cf, m.node.constrs);
+            print_ty_fn(s, m.decl, some(m.ident));
             word(s.s, ";");
             end(s);
         }
@@ -1338,11 +1336,9 @@ fn print_mt(s: ps, mt: ast::mt) {
     print_type(s, mt.ty);
 }
 
-fn print_ty_fn(s: ps, proto: ast::proto, id: option::t<ast::ident>,
-               inputs: [ast::arg], output: @ast::ty, cf: ast::ret_style,
-               constrs: [@ast::constr]) {
+fn print_ty_fn(s: ps, decl: ast::fn_decl, id: option::t<ast::ident>) {
     ibox(s, indent_unit);
-    word(s.s, proto_to_str(proto));
+    word(s.s, proto_to_str(decl.proto));
     alt id { some(id) { word(s.s, " "); word(s.s, id); } _ { } }
     zerobreak(s.s);
     popen(s);
@@ -1353,18 +1349,18 @@ fn print_ty_fn(s: ps, proto: ast::proto, id: option::t<ast::ident>,
         }
         print_type(s, input.ty);
     }
-    commasep(s, inconsistent, inputs, print_arg);
+    commasep(s, inconsistent, decl.inputs, print_arg);
     pclose(s);
-    maybe_print_comment(s, output.span.lo);
-    if output.node != ast::ty_nil {
+    maybe_print_comment(s, decl.output.span.lo);
+    if decl.output.node != ast::ty_nil {
         space_if_not_bol(s);
         ibox(s, indent_unit);
         word_space(s, "->");
-        if cf == ast::noreturn { word_nbsp(s, "!"); }
-        else { print_type(s, output); }
+        if decl.cf == ast::noreturn { word_nbsp(s, "!"); }
+        else { print_type(s, decl.output); }
         end(s);
     }
-    word(s.s, ast_ty_fn_constrs_str(constrs));
+    word(s.s, ast_ty_fn_constrs_str(decl.constraints));
     end(s);
 }
 
diff --git a/src/comp/syntax/visit.rs b/src/comp/syntax/visit.rs
index ce1f67eb7b3..dc91064dba6 100644
--- a/src/comp/syntax/visit.rs
+++ b/src/comp/syntax/visit.rs
@@ -151,8 +151,8 @@ fn visit_ty<E>(t: @ty, e: E, v: vt<E>) {
       }
       ty_obj(tmeths) {
         for m: ty_method in tmeths {
-            for a in m.node.inputs { v.visit_ty(a.ty, e, v); }
-            v.visit_ty(m.node.output, e, v);
+            for a in m.decl.inputs { v.visit_ty(a.ty, e, v); }
+            v.visit_ty(m.decl.output, e, v);
         }
       }
       ty_path(p, _) { visit_path(p, e, v); }