Skip to content

Commit 89110fd

Browse files
committed
Use more deriving(IterBytes) in librustc.
1 parent 75b80ba commit 89110fd

File tree

3 files changed

+23
-275
lines changed

3 files changed

+23
-275
lines changed

src/librustc/middle/trans/common.rs

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ use core::cast;
3636
use core::hashmap::{HashMap};
3737
use core::libc::{c_uint, c_longlong, c_ulonglong};
3838
use core::to_bytes;
39+
use core::str;
40+
use core::vec::raw::to_ptr;
3941
use core::vec;
4042
use syntax::ast::ident;
4143
use syntax::ast_map::{path, path_elt};
@@ -860,7 +862,7 @@ pub fn is_null(val: ValueRef) -> bool {
860862
}
861863

862864
// Used to identify cached monomorphized functions and vtables
863-
#[deriving(Eq)]
865+
#[deriving(Eq,IterBytes)]
864866
pub enum mono_param_id {
865867
mono_precise(ty::t, Option<@~[mono_id]>),
866868
mono_any,
@@ -870,7 +872,7 @@ pub enum mono_param_id {
870872
datum::DatumMode),
871873
}
872874

873-
#[deriving(Eq)]
875+
#[deriving(Eq,IterBytes)]
874876
pub enum MonoDataClass {
875877
MonoBits, // Anything not treated differently from arbitrary integer data
876878
MonoNonNull, // Non-null pointers (used for optional-pointer optimization)
@@ -895,7 +897,7 @@ pub fn mono_data_classify(t: ty::t) -> MonoDataClass {
895897
}
896898

897899

898-
#[deriving(Eq)]
900+
#[deriving(Eq,IterBytes)]
899901
pub struct mono_id_ {
900902
def: ast::def_id,
901903
params: ~[mono_param_id],
@@ -904,40 +906,6 @@ pub struct mono_id_ {
904906

905907
pub type mono_id = @mono_id_;
906908

907-
impl to_bytes::IterBytes for mono_param_id {
908-
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
909-
match *self {
910-
mono_precise(t, ref mids) => {
911-
0u8.iter_bytes(lsb0, f) &&
912-
ty::type_id(t).iter_bytes(lsb0, f) &&
913-
mids.iter_bytes(lsb0, f)
914-
}
915-
916-
mono_any => 1u8.iter_bytes(lsb0, f),
917-
918-
mono_repr(ref a, ref b, ref c, ref d) => {
919-
2u8.iter_bytes(lsb0, f) &&
920-
a.iter_bytes(lsb0, f) &&
921-
b.iter_bytes(lsb0, f) &&
922-
c.iter_bytes(lsb0, f) &&
923-
d.iter_bytes(lsb0, f)
924-
}
925-
}
926-
}
927-
}
928-
929-
impl to_bytes::IterBytes for MonoDataClass {
930-
fn iter_bytes(&self, lsb0: bool, f:to_bytes::Cb) -> bool {
931-
(*self as u8).iter_bytes(lsb0, f)
932-
}
933-
}
934-
935-
impl to_bytes::IterBytes for mono_id_ {
936-
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
937-
self.def.iter_bytes(lsb0, f) && self.params.iter_bytes(lsb0, f)
938-
}
939-
}
940-
941909
pub fn umax(cx: block, a: ValueRef, b: ValueRef) -> ValueRef {
942910
let cond = build::ICmp(cx, lib::llvm::IntULT, a, b);
943911
return build::Select(cx, cond, b, a);

0 commit comments

Comments
 (0)