mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-13 00:04:12 +00:00
Remove unused hokey-hashes from typeck and region inference.
This commit is contained in:
parent
bac89eae48
commit
384906c1e8
@ -2645,120 +2645,10 @@ impl sty : to_bytes::IterBytes {
|
||||
}
|
||||
}
|
||||
|
||||
pure fn hash_bound_region(br: &bound_region) -> uint {
|
||||
match *br { // no idea if this is any good
|
||||
ty::br_self => 0u,
|
||||
ty::br_anon(idx) => 1u | (idx << 2),
|
||||
ty::br_named(ident) => 2u | (ident << 2),
|
||||
ty::br_cap_avoid(id, br) =>
|
||||
3u | (id as uint << 2) | hash_bound_region(br)
|
||||
}
|
||||
}
|
||||
|
||||
fn br_hashmap<V:Copy>() -> HashMap<bound_region, V> {
|
||||
map::HashMap()
|
||||
}
|
||||
|
||||
pure fn hash_region(r: ®ion) -> uint {
|
||||
match *r { // no idea if this is any good
|
||||
re_bound(br) => (hash_bound_region(&br)) << 2u | 0u,
|
||||
re_free(id, br) => ((id as uint) << 4u) |
|
||||
(hash_bound_region(&br)) << 2u | 1u,
|
||||
re_scope(id) => ((id as uint) << 2u) | 2u,
|
||||
re_var(id) => (id.to_uint() << 2u) | 3u,
|
||||
re_static => 4u
|
||||
}
|
||||
}
|
||||
|
||||
// Type hashing.
|
||||
pure fn hash_type_structure(st: &sty) -> uint {
|
||||
pure fn hash_uint(id: uint, n: uint) -> uint { (id << 2u) + n }
|
||||
pure fn hash_def(id: uint, did: ast::def_id) -> uint {
|
||||
let h = (id << 2u) + (did.crate as uint);
|
||||
(h << 2u) + (did.node as uint)
|
||||
}
|
||||
pure fn hash_subty(id: uint, subty: t) -> uint {
|
||||
(id << 2u) + type_id(subty)
|
||||
}
|
||||
pure fn hash_subtys(id: uint, subtys: ~[t]) -> uint {
|
||||
let mut h = id;
|
||||
for vec::each(subtys) |s| { h = (h << 2u) + type_id(*s) }
|
||||
h
|
||||
}
|
||||
pure fn hash_substs(h: uint, substs: &substs) -> uint {
|
||||
let h = hash_subtys(h, substs.tps);
|
||||
h + substs.self_r.map_default(0u, |r| hash_region(&r))
|
||||
}
|
||||
match *st {
|
||||
ty_nil => 0u,
|
||||
ty_bool => 1u,
|
||||
ty_int(t) => match t {
|
||||
ast::ty_i => 2u,
|
||||
ast::ty_char => 3u,
|
||||
ast::ty_i8 => 4u,
|
||||
ast::ty_i16 => 5u,
|
||||
ast::ty_i32 => 6u,
|
||||
ast::ty_i64 => 7u
|
||||
},
|
||||
ty_uint(t) => match t {
|
||||
ast::ty_u => 8u,
|
||||
ast::ty_u8 => 9u,
|
||||
ast::ty_u16 => 10u,
|
||||
ast::ty_u32 => 11u,
|
||||
ast::ty_u64 => 12u
|
||||
},
|
||||
ty_float(t) => match t {
|
||||
ast::ty_f => 13u,
|
||||
ast::ty_f32 => 14u,
|
||||
ast::ty_f64 => 15u
|
||||
},
|
||||
ty_estr(_) => 16u,
|
||||
ty_enum(did, ref substs) => {
|
||||
let mut h = hash_def(18u, did);
|
||||
hash_substs(h, substs)
|
||||
}
|
||||
ty_box(mt) => hash_subty(19u, mt.ty),
|
||||
ty_evec(mt, _) => hash_subty(20u, mt.ty),
|
||||
ty_unboxed_vec(mt) => hash_subty(22u, mt.ty),
|
||||
ty_tup(ts) => hash_subtys(25u, ts),
|
||||
ty_rec(fields) => {
|
||||
let mut h = 26u;
|
||||
for vec::each(fields) |f| { h = hash_subty(h, f.mt.ty); }
|
||||
h
|
||||
}
|
||||
ty_fn(ref f) => {
|
||||
let mut h = 27u;
|
||||
for vec::each(f.sig.inputs) |a| {
|
||||
h = hash_subty(h, a.ty);
|
||||
}
|
||||
hash_subty(h, f.sig.output)
|
||||
}
|
||||
ty_self => 28u,
|
||||
ty_infer(v) => hash_uint(29u, v.to_hash()),
|
||||
ty_param(p) => hash_def(hash_uint(31u, p.idx), p.def_id),
|
||||
ty_type => 32u,
|
||||
ty_bot => 34u,
|
||||
ty_ptr(mt) => hash_subty(35u, mt.ty),
|
||||
ty_uniq(mt) => hash_subty(37u, mt.ty),
|
||||
ty_trait(did, ref substs, _) => {
|
||||
let mut h = hash_def(40u, did);
|
||||
hash_substs(h, substs)
|
||||
}
|
||||
ty_opaque_closure_ptr(ck_block) => 41u,
|
||||
ty_opaque_closure_ptr(ck_box) => 42u,
|
||||
ty_opaque_closure_ptr(ck_uniq) => 43u,
|
||||
ty_opaque_box => 44u,
|
||||
ty_class(did, ref substs) => {
|
||||
let mut h = hash_def(45u, did);
|
||||
hash_substs(h, substs)
|
||||
}
|
||||
ty_rptr(region, mt) => {
|
||||
let mut h = (46u << 2u) + hash_region(®ion);
|
||||
hash_subty(h, mt.ty)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn node_id_to_type(cx: ctxt, id: ast::node_id) -> t {
|
||||
//io::println(fmt!("%?/%?", id, cx.node_types.size()));
|
||||
match smallintmap::find(*cx.node_types, id as uint) {
|
||||
|
@ -312,7 +312,7 @@ use std::map::{HashMap, uint_hash};
|
||||
use std::cell::{Cell, empty_cell};
|
||||
use std::list::{List, Nil, Cons};
|
||||
|
||||
use ty::{region, RegionVid, hash_region};
|
||||
use ty::{region, RegionVid};
|
||||
use region::is_subregion_of;
|
||||
use syntax::codemap;
|
||||
use to_str::to_str;
|
||||
@ -429,14 +429,6 @@ fn CombineMap() -> CombineMap {
|
||||
return HashMap();
|
||||
}
|
||||
|
||||
pure fn hash_constraint(rc: &Constraint) -> uint {
|
||||
match *rc {
|
||||
ConstrainVarSubVar(a, b) => *a ^ *b,
|
||||
ConstrainRegSubVar(ref r, b) => ty::hash_region(r) ^ *b,
|
||||
ConstrainVarSubReg(a, ref r) => *a ^ ty::hash_region(r)
|
||||
}
|
||||
}
|
||||
|
||||
impl RegionVarBindings {
|
||||
fn in_snapshot() -> bool {
|
||||
self.undo_log.len() > 0
|
||||
|
Loading…
Reference in New Issue
Block a user