about summary refs log tree commit diff
path: root/src/comp
diff options
context:
space:
mode:
authorMichael Sullivan <sully@msully.net>2011-07-01 01:48:32 -0700
committerMarijn Haverbeke <marijnh@gmail.com>2011-07-01 12:39:57 +0200
commitee45d54a4e14c8ae809b0b6c3111260a3f39ba40 (patch)
treeaca2b653665b3568da1da2354d6265d8a3f40213 /src/comp
parentb4465aca5ab22447dde52a4a7083d6e3d29e56e2 (diff)
downloadrust-ee45d54a4e14c8ae809b0b6c3111260a3f39ba40.tar.gz
rust-ee45d54a4e14c8ae809b0b6c3111260a3f39ba40.zip
Move autoderefed_ty to ty.rs and rename it type_autoderef.
Diffstat (limited to 'src/comp')
-rw-r--r--src/comp/middle/trans.rs17
-rw-r--r--src/comp/middle/ty.rs12
2 files changed, 15 insertions, 14 deletions
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs
index 6da9a578510..89b147bd473 100644
--- a/src/comp/middle/trans.rs
+++ b/src/comp/middle/trans.rs
@@ -3367,7 +3367,7 @@ fn trans_compare(&@block_ctxt cx0, ast::binop op, &ty::t t0, ValueRef lhs0,
     auto rhs_r = autoderef(cx, rhs0, t0);
     auto rhs = rhs_r.val;
     cx = rhs_r.bcx;
-    auto t = autoderefed_ty(cx.fcx.lcx.ccx, t0);
+    auto t = ty::type_autoderef(cx.fcx.lcx.ccx.tcx, t0);
     // Determine the operation we need.
     // FIXME: Use or-patterns when we have them.
 
@@ -4126,17 +4126,6 @@ fn autoderef(&@block_ctxt cx, ValueRef v, &ty::t t) -> result {
     ret rslt(cx, v1);
 }
 
-fn autoderefed_ty(&@crate_ctxt ccx, &ty::t t) -> ty::t {
-    let ty::t t1 = t;
-    while (true) {
-        alt (ty::struct(ccx.tcx, t1)) {
-            case (ty::ty_box(?mt)) { t1 = mt.ty; }
-            case (_) { break; }
-        }
-    }
-    ret t1;
-}
-
 fn trans_binary(&@block_ctxt cx, ast::binop op, &@ast::expr a, &@ast::expr b)
    -> result {
 
@@ -4199,7 +4188,7 @@ fn trans_binary(&@block_ctxt cx, ast::binop op, &@ast::expr a, &@ast::expr b)
             auto rhty = ty::expr_ty(cx.fcx.lcx.ccx.tcx, b);
             rhs = autoderef(rhs.bcx, rhs.val, rhty);
             ret trans_eager_binop(rhs.bcx, op,
-                                  autoderefed_ty(cx.fcx.lcx.ccx, lhty),
+                                  ty::type_autoderef(cx.fcx.lcx.ccx.tcx,lhty),
                                   lhs.val, rhs.val);
         }
     }
@@ -4910,7 +4899,7 @@ fn trans_path(&@block_ctxt cx, &ast::path p, ast::node_id id) -> lval_result {
 fn trans_field(&@block_ctxt cx, &span sp, ValueRef v, &ty::t t0,
                &ast::ident field, ast::node_id id) -> lval_result {
     auto r = autoderef(cx, v, t0);
-    auto t = autoderefed_ty(cx.fcx.lcx.ccx, t0);
+    auto t = ty::type_autoderef(cx.fcx.lcx.ccx.tcx, t0);
     alt (ty::struct(cx.fcx.lcx.ccx.tcx, t)) {
         case (ty::ty_tup(_)) {
             let uint ix = ty::field_num(cx.fcx.lcx.ccx.sess, sp, field);
diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs
index 5022a1cb2e2..a1f006c64cc 100644
--- a/src/comp/middle/ty.rs
+++ b/src/comp/middle/ty.rs
@@ -176,6 +176,7 @@ export type_is_copyable;
 export type_is_tup_like;
 export type_is_str;
 export type_owns_heap_mem;
+export type_autoderef;
 export type_param;
 export def_to_str;
 export unify;
@@ -1281,6 +1282,17 @@ fn type_param(&ctxt cx, &t ty) -> option::t[uint] {
     ret none[uint];
 }
 
+fn type_autoderef(&ctxt cx, &ty::t t) -> ty::t {
+    let ty::t t1 = t;
+    while (true) {
+        alt (struct(cx, t1)) {
+            case (ty::ty_box(?mt)) { t1 = mt.ty; }
+            case (_) { break; }
+        }
+    }
+    ret t1;
+}
+
 fn def_to_str(&ast::def_id did) -> str { ret #fmt("%d:%d", did._0, did._1); }