about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2011-07-01 16:42:16 -0700
committerPatrick Walton <pcwalton@mimiga.net>2011-07-06 11:09:06 -0700
commitb9a2117475be082b2f93bbcb836b1f05ea52b5e2 (patch)
tree43b3451894d8e309724ded9fdc63a6b22befb954 /src
parent0eb889f9d2512c60a8edbf2a3f06049191c07d93 (diff)
downloadrust-b9a2117475be082b2f93bbcb836b1f05ea52b5e2.tar.gz
rust-b9a2117475be082b2f93bbcb836b1f05ea52b5e2.zip
rustc: Make the various constraint-related types in middle::ty use interior vectors
Diffstat (limited to 'src')
-rw-r--r--src/comp/metadata/tydecode.rs7
-rw-r--r--src/comp/middle/resolve.rs14
-rw-r--r--src/comp/middle/tstate/auxiliary.rs18
-rw-r--r--src/comp/middle/tstate/bitvectors.rs10
-rw-r--r--src/comp/middle/ty.rs8
-rw-r--r--src/comp/middle/typeck.rs8
-rw-r--r--src/comp/syntax/print/pprust.rs9
7 files changed, 56 insertions, 18 deletions
diff --git a/src/comp/metadata/tydecode.rs b/src/comp/metadata/tydecode.rs
index a2c706610a3..de6ff36cd7d 100644
--- a/src/comp/metadata/tydecode.rs
+++ b/src/comp/metadata/tydecode.rs
@@ -103,7 +103,7 @@ fn parse_path(@pstate st, str_def sd) -> ast::path {
 }
 
 fn parse_constr(@pstate st, str_def sd) -> @ty::constr_def {
-    let vec[@ast::constr_arg] args = [];
+    let (@ast::constr_arg)[] args = ~[];
     auto sp = rec(lo=0u,hi=0u); // FIXME: use a real span
     let ast::path pth = parse_path(st, sd);
     let char ignore = next(st) as char;
@@ -113,14 +113,15 @@ fn parse_constr(@pstate st, str_def sd) -> @ty::constr_def {
         alt (peek(st) as char) {
             case ('*') {
                 st.pos += 1u;
-                args += [@respan(sp, ast::carg_base)];
+                args += ~[@respan(sp, ast::carg_base)];
             }
             case (?c) {
                 /* how will we disambiguate between
                  an arg index and a lit argument? */
                 if (c >= '0' && c <= '9') {
                     // FIXME
-                    args += [@respan(sp, ast::carg_ident((c as uint) - 48u))];
+                    args += ~[@respan(sp,
+                                      ast::carg_ident((c as uint) - 48u))];
                     ignore = next(st) as char;
                 }
                 else {
diff --git a/src/comp/middle/resolve.rs b/src/comp/middle/resolve.rs
index 9bab6e6e067..ba45497caab 100644
--- a/src/comp/middle/resolve.rs
+++ b/src/comp/middle/resolve.rs
@@ -138,7 +138,7 @@ fn resolve_crate(session sess, &ast_map::map amap, @ast::crate crate) ->
     auto e =
         @rec(crate_map=new_int_hash[ast::crate_num](),
              def_map=new_int_hash[def](),
-             fn_constrs = new_int_hash[vec[ty::constr_def]](),
+             fn_constrs = new_int_hash[ty::constr_def[]](),
              ast_map=amap,
              imports=new_int_hash[import_state](),
              mod_map=new_int_hash[@indexed_mod](),
@@ -416,8 +416,14 @@ fn resolve_constr(@env e, node_id id, &@ast::constr c, &scopes sc,
     if (option::is_some(new_def)) {
         alt (option::get(new_def)) {
             case (ast::def_fn(?pred_id, ast::pure_fn)) {
+                // FIXME: Remove this vec->ivec conversion.
+                let (@ast::constr_arg_general[uint])[] cag_ivec = ~[];
+                for (@ast::constr_arg_general[uint] cag in c.node.args) {
+                    cag_ivec += ~[cag];
+                }
+
                 let ty::constr_general[uint] c_ =
-                    rec(path=c.node.path, args=c.node.args, id=pred_id);
+                    rec(path=c.node.path, args=cag_ivec, id=pred_id);
                 let ty::constr_def new_constr = respan(c.span, c_);
                 add_constr(e, id, new_constr);
             }
@@ -433,8 +439,8 @@ fn resolve_constr(@env e, node_id id, &@ast::constr c, &scopes sc,
 fn add_constr(&@env e, node_id id, &ty::constr_def c) {
     e.fn_constrs.insert(id,
                         alt (e.fn_constrs.find(id)) {
-                            case (none) { [c] }
-                            case (some(?cs)) { cs + [c] }
+                            case (none) { ~[c] }
+                            case (some(?cs)) { cs + ~[c] }
                         });
 }
 
diff --git a/src/comp/middle/tstate/auxiliary.rs b/src/comp/middle/tstate/auxiliary.rs
index 04daaff3d4e..3b8d689bc46 100644
--- a/src/comp/middle/tstate/auxiliary.rs
+++ b/src/comp/middle/tstate/auxiliary.rs
@@ -504,7 +504,7 @@ fn constraints(&fn_ctxt fcx) -> vec[norm_constraint] {
     ret rslt;
 }
 
-fn match_args(&fn_ctxt fcx, vec[pred_desc] occs, vec[@constr_arg_use] occ) ->
+fn match_args(&fn_ctxt fcx, vec[pred_desc] occs, &(@constr_arg_use)[] occ) ->
    uint {
     log "match_args: looking at " +
         constr_args_to_str(std::util::fst[ident, def_id], occ);
@@ -513,7 +513,13 @@ fn match_args(&fn_ctxt fcx, vec[pred_desc] occs, vec[@constr_arg_use] occ) ->
         fn eq(&tup(ident, def_id) p, &tup(ident, def_id) q) -> bool {
             ret p._1 == q._1;
         }
-        if (ty::args_eq(eq, pd.node.args, occ)) { ret pd.node.bit_num; }
+
+        // FIXME: Remove this vec->ivec conversion.
+        let (@constr_arg_use)[] cau_ivec = ~[];
+        for (@constr_arg_use cau in pd.node.args) {
+            cau_ivec += ~[cau];
+        }
+        if (ty::args_eq(eq, cau_ivec, occ)) { ret pd.node.bit_num; }
     }
     fcx.ccx.tcx.sess.bug("match_args: no match for occurring args");
 }
@@ -593,8 +599,14 @@ fn expr_to_constr(ty::ctxt tcx, &@expr e) -> constr {
 }
 
 fn pred_desc_to_str(&pred_desc p) -> str {
+    // FIXME: Remove this vec->ivec conversion.
+    let (@constr_arg_use)[] cau_ivec = ~[];
+    for (@constr_arg_use cau in p.node.args) {
+        cau_ivec += ~[cau];
+    }
+
     ret "<" + uint::str(p.node.bit_num) + ", " +
-        constr_args_to_str(std::util::fst[ident, def_id], p.node.args) + ">";
+        constr_args_to_str(std::util::fst[ident, def_id], cau_ivec) + ">";
 }
 
 fn substitute_constr_args(&ty::ctxt cx, &vec[@expr] actuals,
diff --git a/src/comp/middle/tstate/bitvectors.rs b/src/comp/middle/tstate/bitvectors.rs
index 3dea3cef30d..371cfc0580f 100644
--- a/src/comp/middle/tstate/bitvectors.rs
+++ b/src/comp/middle/tstate/bitvectors.rs
@@ -5,6 +5,7 @@ import std::option::*;
 import std::vec;
 import std::vec::len;
 import std::vec::slice;
+import aux::constr_arg_use;
 import aux::local_node_id_to_def;
 import aux::fn_ctxt;
 import aux::fn_info;
@@ -63,7 +64,14 @@ fn bit_num(&fn_ctxt fcx, &constr_ c) -> uint {
         }
         case (npred(_, ?args)) {
             alt (rslt) {
-                case (cpred(_, ?descs)) { ret match_args(fcx, *descs, args); }
+                case (cpred(_, ?descs)) {
+                    // FIXME: Remove this vec->ivec conversion.
+                    let (@constr_arg_use)[] cau_ivec = ~[];
+                    for (@constr_arg_use cau in args) {
+                        cau_ivec += ~[cau];
+                    }
+                    ret match_args(fcx, *descs, cau_ivec);
+                }
                 case (_) {
                     fcx.ccx.tcx.sess.bug("bit_num: asked for pred constraint,"
                                              + " found an init constraint");
diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs
index 3d60eba98af..40aeb491bcc 100644
--- a/src/comp/middle/ty.rs
+++ b/src/comp/middle/ty.rs
@@ -198,7 +198,7 @@ type method =
         controlflow cf,
         (@constr_def)[] constrs);
 
-type constr_table = hashmap[ast::node_id, vec[constr_def]]; 
+type constr_table = hashmap[ast::node_id, constr_def[]];
 
 type mt = rec(t ty, ast::mutability mut);
 
@@ -281,7 +281,7 @@ tag sty {
 type constr_def = spanned[constr_general[uint]];
 
 type constr_general[T] =
-    rec(ast::path path, vec[@constr_arg_general[T]] args, def_id id);
+    rec(ast::path path, (@constr_arg_general[T])[] args, def_id id);
 
 
 // Data structures used in type unification
@@ -1438,8 +1438,8 @@ fn arg_eq[T](&fn(&T, &T) -> bool  eq, @ast::constr_arg_general[T] a,
     }
 }
 
-fn args_eq[T](fn(&T, &T) -> bool  eq, vec[@ast::constr_arg_general[T]] a,
-              vec[@ast::constr_arg_general[T]] b) -> bool {
+fn args_eq[T](fn(&T, &T) -> bool eq, &(@ast::constr_arg_general[T])[] a,
+              &(@ast::constr_arg_general[T])[] b) -> bool {
     let uint i = 0u;
     for (@ast::constr_arg_general[T] arg in a) {
         if (!arg_eq(eq, arg, b.(i))) { ret false; }
diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs
index daf2cc75be5..936b44c92aa 100644
--- a/src/comp/middle/typeck.rs
+++ b/src/comp/middle/typeck.rs
@@ -2355,7 +2355,13 @@ fn ast_constr_to_constr(ty::ctxt tcx, &@ast::constr c)
     -> @ty::constr_def {
     alt (tcx.def_map.find(c.node.id)) {
         case (some(ast::def_fn(?pred_id, ast::pure_fn))) {
-            ret @respan(c.span, rec(path=c.node.path, args=c.node.args,
+            // FIXME: Remove this vec->ivec conversion.
+            let (@ast::constr_arg_general[uint])[] cag_ivec = ~[];
+            for (@ast::constr_arg_general[uint] cag in c.node.args) {
+                cag_ivec += ~[cag];
+            }
+
+            ret @respan(c.span, rec(path=c.node.path, args=cag_ivec,
                                     id=pred_id));
         }
         case (_) {
diff --git a/src/comp/syntax/print/pprust.rs b/src/comp/syntax/print/pprust.rs
index 86ae4cbd295..beab560b8d5 100644
--- a/src/comp/syntax/print/pprust.rs
+++ b/src/comp/syntax/print/pprust.rs
@@ -1421,7 +1421,7 @@ fn next_comment(&ps s) -> option::t[lexer::cmnt] {
 
 
 fn constr_args_to_str[T](fn(&T) -> str  f,
-                         &vec[@ast::constr_arg_general[T]] args) -> str {
+                         &(@ast::constr_arg_general[T])[] args) -> str {
     auto comma = false;
     auto s = "(";
     for (@ast::constr_arg_general[T] a in args) {
@@ -1447,8 +1447,13 @@ fn constr_arg_to_str[T](fn(&T) -> str  f, &ast::constr_arg_general_[T] c) ->
 fn uint_to_str(&uint i) -> str { ret uint::str(i); }
 
 fn ast_constr_to_str(&@ast::constr c) -> str {
+    // TODO: Remove this vec->ivec conversion.
+    auto cag_ivec = ~[];
+    for (@ast::constr_arg_general[uint] cag in c.node.args) {
+        cag_ivec += ~[cag];
+    }
     ret ast::path_to_str(c.node.path) +
-            constr_args_to_str(uint_to_str, c.node.args);
+            constr_args_to_str(uint_to_str, cag_ivec);
 }
 
 fn ast_constrs_str(&vec[@ast::constr] constrs) -> str {