about summary refs log tree commit diff
path: root/src/comp
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2011-07-01 11:32:40 -0700
committerPatrick Walton <pcwalton@mimiga.net>2011-07-01 11:33:17 -0700
commit6720ea760df41df82af880b593e5b6023608d6cd (patch)
tree461da49b594b11f6d13c36e7b593fa1603c11c06 /src/comp
parent172c5633c4fd6a3868ded1f6afdd5b519edb98ed (diff)
downloadrust-6720ea760df41df82af880b593e5b6023608d6cd.tar.gz
rust-6720ea760df41df82af880b593e5b6023608d6cd.zip
rustc: Change methods in ty::t to use interior vectors
Diffstat (limited to 'src/comp')
-rw-r--r--src/comp/metadata/tydecode.rs14
-rw-r--r--src/comp/middle/ty.rs44
-rw-r--r--src/comp/middle/typeck.rs27
-rw-r--r--src/comp/pretty/ppaux.rs6
4 files changed, 48 insertions, 43 deletions
diff --git a/src/comp/metadata/tydecode.rs b/src/comp/metadata/tydecode.rs
index d174dc7e3a1..f9df56bc6d7 100644
--- a/src/comp/metadata/tydecode.rs
+++ b/src/comp/metadata/tydecode.rs
@@ -230,7 +230,7 @@ fn parse_ty(@pstate st, str_def sd) -> ty::t {
         }
         case ('O') {
             assert (next(st) as char == '[');
-            let vec[ty::method] methods = [];
+            let ty::method[] methods = ~[];
             while (peek(st) as char != ']') {
                 auto proto;
                 alt (next(st) as char) {
@@ -243,12 +243,12 @@ fn parse_ty(@pstate st, str_def sd) -> ty::t {
                 }
                 auto func = parse_ty_fn(st, sd);
                 methods +=
-                    [rec(proto=proto,
-                         ident=name,
-                         inputs=func._0,
-                         output=func._1,
-                         cf=func._2,
-                         constrs=func._3)];
+                    ~[rec(proto=proto,
+                          ident=name,
+                          inputs=func._0,
+                          output=func._1,
+                          cf=func._2,
+                          constrs=func._3)];
             }
             st.pos += 1u;
             ret ty::mk_obj(st.tcx, methods);
diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs
index 5e8b79df767..7c8a525c923 100644
--- a/src/comp/middle/ty.rs
+++ b/src/comp/middle/ty.rs
@@ -268,7 +268,7 @@ tag sty {
     ty_rec(field[]);
     ty_fn(ast::proto, arg[], t, controlflow, vec[@constr_def]);
     ty_native_fn(ast::native_abi, arg[], t);
-    ty_obj(vec[method]);
+    ty_obj(method[]);
     ty_res(def_id, t, vec[t]);
     ty_var(int); // type variable
     ty_param(uint); // fn/tag type param
@@ -603,7 +603,7 @@ fn mk_native_fn(&ctxt cx, &ast::native_abi abi, &arg[] args, &t ty) -> t {
     ret gen_ty(cx, ty_native_fn(abi, args, ty));
 }
 
-fn mk_obj(&ctxt cx, &vec[method] meths) -> t {
+fn mk_obj(&ctxt cx, &method[] meths) -> t {
     ret gen_ty(cx, ty_obj(meths));
 }
 
@@ -811,7 +811,7 @@ fn fold_ty(&ctxt cx, fold_mode fld, t ty_0) -> t {
                                         fold_ty(cx, fld, ret_ty)), ty);
         }
         case (ty_obj(?methods)) {
-            let vec[method] new_methods = [];
+            let method[] new_methods = ~[];
             for (method m in methods) {
                 let arg[] new_args = ~[];
                 for (arg a in m.inputs) {
@@ -819,12 +819,12 @@ fn fold_ty(&ctxt cx, fold_mode fld, t ty_0) -> t {
                                       ty=fold_ty(cx, fld, a.ty))];
                 }
                 new_methods +=
-                    [rec(proto=m.proto,
-                         ident=m.ident,
-                         inputs=new_args,
-                         output=fold_ty(cx, fld, m.output),
-                         cf=m.cf,
-                         constrs=m.constrs)];
+                    ~[rec(proto=m.proto,
+                          ident=m.ident,
+                          inputs=new_args,
+                          output=fold_ty(cx, fld, m.output),
+                          cf=m.cf,
+                          constrs=m.constrs)];
             }
             ty = copy_cname(cx, mk_obj(cx, new_methods), ty);
         }
@@ -1634,8 +1634,8 @@ fn equal_type_structures(&sty a, &sty b) -> bool {
         case (ty_obj(?methods_a)) {
             alt (b) {
                 case (ty_obj(?methods_b)) {
-                    auto len = vec::len[method](methods_a);
-                    if (len != vec::len[method](methods_b)) { ret false; }
+                    auto len = ivec::len[method](methods_a);
+                    if (len != ivec::len[method](methods_b)) { ret false; }
                     auto i = 0u;
                     while (i < len) {
                         auto m_a = methods_a.(i);
@@ -1947,17 +1947,17 @@ fn field_idx(&session::session sess, &span sp, &ast::ident id,
 }
 
 fn method_idx(&session::session sess, &span sp, &ast::ident id,
-              &vec[method] meths) -> uint {
+              &method[] meths) -> uint {
     let uint i = 0u;
     for (method m in meths) { if (str::eq(m.ident, id)) { ret i; } i += 1u; }
     sess.span_fatal(sp, "unknown method '" + id + "' of obj");
 }
 
-fn sort_methods(&vec[method] meths) -> vec[method] {
+fn sort_methods(&method[] meths) -> method[] {
     fn method_lteq(&method a, &method b) -> bool {
         ret str::lteq(a.ident, b.ident);
     }
-    ret std::sort::merge_sort[method](bind method_lteq(_, _), meths);
+    ret std::sort::ivector::merge_sort[method](bind method_lteq(_, _), meths);
 }
 
 fn is_lval(&@ast::expr expr) -> bool {
@@ -2197,12 +2197,12 @@ mod unify {
         }
     }
     fn unify_obj(&@ctxt cx, &t expected, &t actual,
-                 &vec[method] expected_meths, &vec[method] actual_meths) ->
+                 &method[] expected_meths, &method[] actual_meths) ->
        result {
-        let vec[method] result_meths = [];
+        let method[] result_meths = ~[];
         let uint i = 0u;
-        let uint expected_len = vec::len[method](expected_meths);
-        let uint actual_len = vec::len[method](actual_meths);
+        let uint expected_len = ivec::len[method](expected_meths);
+        let uint actual_len = ivec::len[method](actual_meths);
         if (expected_len != actual_len) { ret ures_err(terr_meth_count); }
         while (i < expected_len) {
             auto e_meth = expected_meths.(i);
@@ -2220,10 +2220,10 @@ mod unify {
                     alt (struct(cx.tcx, tfn)) {
                         case (ty_fn(?proto, ?ins, ?out, ?cf, ?constrs)) {
                             result_meths +=
-                                [rec(inputs=ins,
-                                     output=out,
-                                     cf=cf,
-                                     constrs=constrs with e_meth)];
+                                ~[rec(inputs=ins,
+                                      output=out,
+                                      cf=cf,
+                                      constrs=constrs with e_meth)];
                         }
                     }
                 }
diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs
index 1a2670f8249..0b14ddd25df 100644
--- a/src/comp/middle/typeck.rs
+++ b/src/comp/middle/typeck.rs
@@ -336,7 +336,7 @@ fn ast_ty_to_ty(&ty::ctxt tcx, &ty_getter getter, &@ast::ty ast_ty) -> ty::t {
             cname = some(path_to_str(path));
         }
         case (ast::ty_obj(?meths)) {
-            let vec[ty::method] tmeths = [];
+            let ty::method[] tmeths = ~[];
             for (ast::ty_method m in meths) {
                 auto ins = ~[];
                 for (ast::ty_arg ta in m.node.inputs) {
@@ -355,7 +355,7 @@ fn ast_ty_to_ty(&ty::ctxt tcx, &ty_getter getter, &@ast::ty ast_ty) -> ty::t {
                         output=out,
                         cf=m.node.cf,
                         constrs=out_constrs);
-                vec::push[ty::method](tmeths, new_m);
+                tmeths += ~[new_m];
             }
             typ = ty::mk_obj(tcx, ty::sort_methods(tmeths));
         }
@@ -681,9 +681,12 @@ mod collect {
             write::ty_only(cx.tcx, variant.node.id, result_ty);
         }
     }
-    fn get_obj_method_types(&@ctxt cx, &ast::_obj object) -> vec[ty::method] {
-        ret vec::map[@ast::method,
-                     method](bind ty_of_method(cx, _), object.methods);
+    fn get_obj_method_types(&@ctxt cx, &ast::_obj object) -> ty::method[] {
+        auto meths = ~[];
+        for (@ast::method am in object.methods) {
+            meths += ~[ty_of_method(cx, am)];
+        }
+        ret meths;
     }
     fn convert(@ctxt cx, @mutable option::t[ast::native_abi] abi,
                &@ast::item it) {
@@ -2069,7 +2072,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
                     let uint ix =
                         ty::method_idx(fcx.ccx.tcx.sess, expr.span, field,
                                        methods);
-                    if (ix >= vec::len[ty::method](methods)) {
+                    if (ix >= ivec::len[ty::method](methods)) {
                         fcx.ccx.tcx.sess.span_fatal(expr.span,
                                                   "bad index on obj");
                     }
@@ -2213,11 +2216,13 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
                         constrs=out_constrs);
             }
             fn get_anon_obj_method_types(@crate_ctxt ccx,
-                                         &ast::anon_obj anon_obj) ->
-               vec[ty::method] {
-                ret vec::map[@ast::method,
-                             method](bind ty_of_method(ccx, _),
-                                     anon_obj.methods);
+                                         &ast::anon_obj anon_obj)
+                -> ty::method[] {
+                auto meths = ~[];
+                for (@ast::method am in anon_obj.methods) {
+                    meths += ~[ty_of_method(ccx, am)];
+                }
+                ret meths;
             }
             auto method_types = get_anon_obj_method_types(fcx.ccx, anon_obj);
             auto ot = ty::mk_obj(fcx.ccx.tcx, ty::sort_methods(method_types));
diff --git a/src/comp/pretty/ppaux.rs b/src/comp/pretty/ppaux.rs
index fbe4ea9034c..b928aea4655 100644
--- a/src/comp/pretty/ppaux.rs
+++ b/src/comp/pretty/ppaux.rs
@@ -135,9 +135,9 @@ fn ty_to_str(&ctxt cx, &t typ) -> str {
                            ast::return, []);
         }
         case (ty_obj(?meths)) {
-            auto f = bind method_to_str(cx, _);
-            auto m = vec::map[method, str](f, meths);
-            s += "obj {\n\t" + str::connect(m, "\n\t") + "\n}";
+            auto strs = [];
+            for (method m in meths) { strs += [method_to_str(cx, m)]; }
+            s += "obj {\n\t" + str::connect(strs, "\n\t") + "\n}";
         }
         case (ty_res(?id, _, _)) {
             s += "<resource#" + istr(id._0) + ":" + istr(id._1) + ">";