about summary refs log tree commit diff
path: root/src/rustc
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2012-05-23 00:38:39 -0700
committerBrian Anderson <banderson@mozilla.com>2012-05-23 00:43:02 -0700
commit4756556748fe7fa247c02f36dc481c8eeae9908d (patch)
treea914d555843f7325f8d3120e262cedc914b17a81 /src/rustc
parent8ec467d521e6e39f80a0c74c049a5aa719a01dde (diff)
downloadrust-4756556748fe7fa247c02f36dc481c8eeae9908d.tar.gz
rust-4756556748fe7fa247c02f36dc481c8eeae9908d.zip
rustc: Move new_def_hash to ast_util
Diffstat (limited to 'src/rustc')
-rw-r--r--src/rustc/metadata/cstore.rs1
-rw-r--r--src/rustc/middle/region.rs2
-rw-r--r--src/rustc/middle/resolve.rs6
-rw-r--r--src/rustc/middle/trans/base.rs4
-rw-r--r--src/rustc/middle/trans/shape.rs4
-rw-r--r--src/rustc/middle/tstate/collect_locals.rs1
-rw-r--r--src/rustc/middle/tstate/pre_post_conditions.rs2
-rw-r--r--src/rustc/middle/ty.rs7
-rw-r--r--src/rustc/util/common.rs17
9 files changed, 14 insertions, 30 deletions
diff --git a/src/rustc/metadata/cstore.rs b/src/rustc/metadata/cstore.rs
index b3907d84f48..ceabf27d622 100644
--- a/src/rustc/metadata/cstore.rs
+++ b/src/rustc/metadata/cstore.rs
@@ -4,6 +4,7 @@
 import std::map;
 import std::map::hashmap;
 import syntax::{ast, attr};
+import syntax::ast_util::new_def_hash;
 import util::common::*;
 
 export cstore::{};
diff --git a/src/rustc/middle/region.rs b/src/rustc/middle/region.rs
index b12836e6125..51109c1155a 100644
--- a/src/rustc/middle/region.rs
+++ b/src/rustc/middle/region.rs
@@ -137,7 +137,7 @@ import middle::ty;
 import syntax::{ast, visit};
 import syntax::codemap::span;
 import syntax::print::pprust;
-import util::common::new_def_hash;
+import syntax::ast_util::new_def_hash;
 
 import std::list;
 import std::list::list;
diff --git a/src/rustc/middle/resolve.rs b/src/rustc/middle/resolve.rs
index 9521b0d1488..3c713329268 100644
--- a/src/rustc/middle/resolve.rs
+++ b/src/rustc/middle/resolve.rs
@@ -1,7 +1,7 @@
 import syntax::{ast, ast_util, codemap, ast_map};
 import syntax::ast::*;
 import ast::{ident, fn_ident, def, def_id, node_id};
-import syntax::ast_util::{local_def, def_id_of_def,
+import syntax::ast_util::{local_def, def_id_of_def, new_def_hash,
                           class_item_ident, path_to_ident};
 import pat_util::*;
 
@@ -73,10 +73,10 @@ type ext_hash = hashmap<{did: def_id, ident: str, ns: namespace}, def>;
 fn new_ext_hash() -> ext_hash {
     type key = {did: def_id, ident: str, ns: namespace};
     fn hash(v: key) -> uint {
-        str::hash(v.ident) + util::common::hash_def(v.did) + v.ns as uint
+        str::hash(v.ident) + ast_util::hash_def(v.did) + v.ns as uint
     }
     fn eq(v1: key, v2: key) -> bool {
-        ret util::common::def_eq(v1.did, v2.did) &&
+        ret ast_util::def_eq(v1.did, v2.did) &&
             str::eq(v1.ident, v2.ident) && v1.ns == v2.ns;
     }
     std::map::hashmap(hash, {|a, b| a == b})
diff --git a/src/rustc/middle/trans/base.rs b/src/rustc/middle/trans/base.rs
index a4970268efd..07cbc4a96bc 100644
--- a/src/rustc/middle/trans/base.rs
+++ b/src/rustc/middle/trans/base.rs
@@ -5492,10 +5492,10 @@ fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt,
           discrims: ast_util::new_def_id_hash::<ValueRef>(),
           discrim_symbols: int_hash::<str>(),
           tydescs: ty::new_ty_hash(),
-          external: util::common::new_def_hash(),
+          external: ast_util::new_def_hash(),
           monomorphized: map::hashmap(hash_mono_id, {|a, b| a == b}),
           monomorphizing: ast_util::new_def_id_hash(),
-          type_use_cache: util::common::new_def_hash(),
+          type_use_cache: ast_util::new_def_hash(),
           vtables: map::hashmap(hash_mono_id, {|a, b| a == b}),
           const_cstr_cache: map::str_hash(),
           module_data: str_hash::<ValueRef>(),
diff --git a/src/rustc/middle/trans/shape.rs b/src/rustc/middle/trans/shape.rs
index 9e3c6255c89..d5517dc5ee2 100644
--- a/src/rustc/middle/trans/shape.rs
+++ b/src/rustc/middle/trans/shape.rs
@@ -11,7 +11,7 @@ import back::abi;
 import middle::ty;
 import middle::ty::field;
 import syntax::ast;
-import syntax::ast_util::dummy_sp;
+import syntax::ast_util::{dummy_sp, new_def_hash};
 import syntax::util::interner;
 import util::common;
 import syntax::codemap::span;
@@ -273,7 +273,7 @@ fn mk_ctxt(llmod: ModuleRef) -> ctxt {
 
     ret {mut next_tag_id: 0u16,
          pad: 0u16,
-         tag_id_to_index: common::new_def_hash(),
+         tag_id_to_index: new_def_hash(),
          tag_order: dvec(),
          resources: interner::mk(hash_res_info, {|a, b| a == b}),
          llshapetablesty: llshapetablesty,
diff --git a/src/rustc/middle/tstate/collect_locals.rs b/src/rustc/middle/tstate/collect_locals.rs
index b6f1de95984..88a353f4cd8 100644
--- a/src/rustc/middle/tstate/collect_locals.rs
+++ b/src/rustc/middle/tstate/collect_locals.rs
@@ -3,7 +3,6 @@ import pat_util::*;
 import syntax::ast::*;
 import syntax::ast_util::*;
 import syntax::visit;
-import util::common::new_def_hash;
 import syntax::codemap::span;
 import syntax::ast_util::respan;
 import driver::session::session;
diff --git a/src/rustc/middle/tstate/pre_post_conditions.rs b/src/rustc/middle/tstate/pre_post_conditions.rs
index 7b8c864580d..3d1db2f6e66 100644
--- a/src/rustc/middle/tstate/pre_post_conditions.rs
+++ b/src/rustc/middle/tstate/pre_post_conditions.rs
@@ -9,7 +9,7 @@ import pat_util::*;
 import syntax::ast::*;
 import syntax::ast_util::*;
 import syntax::visit;
-import util::common::{new_def_hash, log_expr, field_exprs,
+import util::common::{log_expr, field_exprs,
                       has_nonlocal_exits, log_stmt};
 import syntax::codemap::span;
 import driver::session::session;
diff --git a/src/rustc/middle/ty.rs b/src/rustc/middle/ty.rs
index 7ad4bb0103b..84b4d4f6594 100644
--- a/src/rustc/middle/ty.rs
+++ b/src/rustc/middle/ty.rs
@@ -6,7 +6,8 @@ import session::session;
 import syntax::{ast, ast_map};
 import syntax::ast::*;
 import syntax::ast_util;
-import syntax::ast_util::{is_local, local_def, split_class_items};
+import syntax::ast_util::{is_local, local_def, split_class_items,
+                          new_def_hash};
 import syntax::codemap::span;
 import metadata::csearch;
 import util::common::*;
@@ -478,7 +479,7 @@ fn mk_ctxt(s: session::session, dm: resolve::def_map, amap: ast_map::map,
       items: amap,
       intrinsic_ifaces: map::str_hash(),
       freevars: freevars,
-      tcache: new_def_hash(),
+      tcache: ast_util::new_def_hash(),
       rcache: mk_rcache(),
       short_names_cache: new_ty_hash(),
       needs_drop_cache: new_ty_hash(),
@@ -2524,7 +2525,7 @@ fn enum_variant_with_id(cx: ctxt, enum_id: ast::def_id,
     let mut i = 0u;
     while i < vec::len::<variant_info>(*variants) {
         let variant = variants[i];
-        if def_eq(variant.id, variant_id) { ret variant; }
+        if ast_util::def_eq(variant.id, variant_id) { ret variant; }
         i += 1u;
     }
     cx.sess.bug("enum_variant_with_id(): no variant exists with that ID");
diff --git a/src/rustc/util/common.rs b/src/rustc/util/common.rs
index 0cd45e0dcf5..daab9eb33f1 100644
--- a/src/rustc/util/common.rs
+++ b/src/rustc/util/common.rs
@@ -25,23 +25,6 @@ fn indenter() -> _indenter {
 
 type flag = hashmap<str, ()>;
 
-fn def_eq(a: ast::def_id, b: ast::def_id) -> bool {
-    ret a.crate == b.crate && a.node == b.node;
-}
-
-fn hash_def(d: ast::def_id) -> uint {
-    let mut h = 5381u;
-    h = (h << 5u) + h ^ (d.crate as uint);
-    h = (h << 5u) + h ^ (d.node as uint);
-    ret h;
-}
-
-fn new_def_hash<V: copy>() -> std::map::hashmap<ast::def_id, V> {
-    let hasher: std::map::hashfn<ast::def_id> = hash_def;
-    let eqer: std::map::eqfn<ast::def_id> = def_eq;
-    ret std::map::hashmap::<ast::def_id, V>(hasher, eqer);
-}
-
 fn field_expr(f: ast::field) -> @ast::expr { ret f.node.expr; }
 
 fn field_exprs(fields: [ast::field]) -> [@ast::expr] {