mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-16 02:24:35 +00:00
auto merge of #6635 : brson/rust/snapshot, r=brson
This commit is contained in:
commit
2e6cda254a
@ -24,20 +24,6 @@ pub mod rusti {
|
||||
}
|
||||
|
||||
/// Casts the value at `src` to U. The two types must have the same length.
|
||||
#[cfg(not(stage0))]
|
||||
pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
|
||||
let mut dest: U = unstable::intrinsics::uninit();
|
||||
{
|
||||
let dest_ptr: *mut u8 = rusti::transmute(&mut dest);
|
||||
let src_ptr: *u8 = rusti::transmute(src);
|
||||
unstable::intrinsics::memmove64(dest_ptr,
|
||||
src_ptr,
|
||||
sys::size_of::<U>() as u64);
|
||||
}
|
||||
dest
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
|
||||
let mut dest: U = unstable::intrinsics::init();
|
||||
{
|
||||
|
@ -12,9 +12,6 @@
|
||||
|
||||
use option::{None, Option, Some};
|
||||
use str;
|
||||
#[cfg(stage0)]
|
||||
use str::StrSlice;
|
||||
#[cfg(not(stage0))]
|
||||
use str::{StrSlice, OwnedStr};
|
||||
use u32;
|
||||
use uint;
|
||||
@ -191,21 +188,6 @@ pub fn from_digit(num: uint, radix: uint) -> Option<char> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub fn escape_unicode(c: char) -> ~str {
|
||||
let s = u32::to_str_radix(c as u32, 16u);
|
||||
let (c, pad) = (if c <= '\xff' { ('x', 2u) }
|
||||
else if c <= '\uffff' { ('u', 4u) }
|
||||
else { ('U', 8u) });
|
||||
assert!(str::len(s) <= pad);
|
||||
let mut out = ~"\\";
|
||||
str::push_str(&mut out, str::from_char(c));
|
||||
for uint::range(str::len(s), pad) |_i|
|
||||
{ str::push_str(&mut out, ~"0"); }
|
||||
str::push_str(&mut out, s);
|
||||
out
|
||||
}
|
||||
|
||||
///
|
||||
/// Return the hexadecimal unicode escape of a char.
|
||||
///
|
||||
@ -215,7 +197,6 @@ pub fn escape_unicode(c: char) -> ~str {
|
||||
/// - chars in [0x100,0xffff] get 4-digit escapes: `\\uNNNN`
|
||||
/// - chars above 0x10000 get 8-digit escapes: `\\UNNNNNNNN`
|
||||
///
|
||||
#[cfg(not(stage0))]
|
||||
pub fn escape_unicode(c: char) -> ~str {
|
||||
let s = u32::to_str_radix(c as u32, 16u);
|
||||
let (c, pad) = cond!(
|
||||
@ -258,23 +239,7 @@ pub fn escape_default(c: char) -> ~str {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub fn len_utf8_bytes(c: char) -> uint {
|
||||
static max_one_b: uint = 128u;
|
||||
static max_two_b: uint = 2048u;
|
||||
static max_three_b: uint = 65536u;
|
||||
static max_four_b: uint = 2097152u;
|
||||
|
||||
let code = c as uint;
|
||||
if code < max_one_b { 1u }
|
||||
else if code < max_two_b { 2u }
|
||||
else if code < max_three_b { 3u }
|
||||
else if code < max_four_b { 4u }
|
||||
else { fail!("invalid character!") }
|
||||
}
|
||||
|
||||
/// Returns the amount of bytes this character would need if encoded in utf8
|
||||
#[cfg(not(stage0))]
|
||||
pub fn len_utf8_bytes(c: char) -> uint {
|
||||
static MAX_ONE_B: uint = 128u;
|
||||
static MAX_TWO_B: uint = 2048u;
|
||||
|
@ -127,33 +127,6 @@ struct AnnihilateStats {
|
||||
n_bytes_freed: uint
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
unsafe fn each_live_alloc(read_next_before: bool,
|
||||
f: &fn(box: *mut BoxRepr, uniq: bool) -> bool) {
|
||||
//! Walks the internal list of allocations
|
||||
|
||||
use managed;
|
||||
|
||||
let task: *Task = transmute(rustrt::rust_get_task());
|
||||
let box = (*task).boxed_region.live_allocs;
|
||||
let mut box: *mut BoxRepr = transmute(copy box);
|
||||
while box != mut_null() {
|
||||
let next_before = transmute(copy (*box).header.next);
|
||||
let uniq =
|
||||
(*box).header.ref_count == managed::raw::RC_MANAGED_UNIQUE;
|
||||
|
||||
if !f(box, uniq) {
|
||||
return;
|
||||
}
|
||||
|
||||
if read_next_before {
|
||||
box = next_before;
|
||||
} else {
|
||||
box = transmute(copy (*box).header.next);
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
unsafe fn each_live_alloc(read_next_before: bool,
|
||||
f: &fn(box: *mut BoxRepr, uniq: bool) -> bool) -> bool {
|
||||
//! Walks the internal list of allocations
|
||||
|
@ -30,31 +30,15 @@ pub trait Map<K, V>: Mutable {
|
||||
fn contains_key(&self, key: &K) -> bool;
|
||||
|
||||
// Visits all keys and values
|
||||
#[cfg(stage0)]
|
||||
fn each<'a>(&'a self, f: &fn(&K, &'a V) -> bool);
|
||||
// Visits all keys and values
|
||||
#[cfg(not(stage0))]
|
||||
fn each<'a>(&'a self, f: &fn(&K, &'a V) -> bool) -> bool;
|
||||
|
||||
/// Visit all keys
|
||||
#[cfg(stage0)]
|
||||
fn each_key(&self, f: &fn(&K) -> bool);
|
||||
/// Visit all keys
|
||||
#[cfg(not(stage0))]
|
||||
fn each_key(&self, f: &fn(&K) -> bool) -> bool;
|
||||
|
||||
/// Visit all values
|
||||
#[cfg(stage0)]
|
||||
fn each_value<'a>(&'a self, f: &fn(&'a V) -> bool);
|
||||
/// Visit all values
|
||||
#[cfg(not(stage0))]
|
||||
fn each_value<'a>(&'a self, f: &fn(&'a V) -> bool) -> bool;
|
||||
|
||||
/// Iterate over the map and mutate the contained values
|
||||
#[cfg(stage0)]
|
||||
fn mutate_values(&mut self, f: &fn(&K, &mut V) -> bool);
|
||||
/// Iterate over the map and mutate the contained values
|
||||
#[cfg(not(stage0))]
|
||||
fn mutate_values(&mut self, f: &fn(&K, &mut V) -> bool) -> bool;
|
||||
|
||||
/// Return a reference to the value corresponding to the key
|
||||
@ -81,43 +65,6 @@ pub trait Map<K, V>: Mutable {
|
||||
fn pop(&mut self, k: &K) -> Option<V>;
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub trait Set<T>: Mutable {
|
||||
/// Return true if the set contains a value
|
||||
fn contains(&self, value: &T) -> bool;
|
||||
|
||||
/// Add a value to the set. Return true if the value was not already
|
||||
/// present in the set.
|
||||
fn insert(&mut self, value: T) -> bool;
|
||||
|
||||
/// Remove a value from the set. Return true if the value was
|
||||
/// present in the set.
|
||||
fn remove(&mut self, value: &T) -> bool;
|
||||
|
||||
/// Return true if the set has no elements in common with `other`.
|
||||
/// This is equivalent to checking for an empty intersection.
|
||||
fn is_disjoint(&self, other: &Self) -> bool;
|
||||
|
||||
/// Return true if the set is a subset of another
|
||||
fn is_subset(&self, other: &Self) -> bool;
|
||||
|
||||
/// Return true if the set is a superset of another
|
||||
fn is_superset(&self, other: &Self) -> bool;
|
||||
|
||||
/// Visit the values representing the difference
|
||||
fn difference(&self, other: &Self, f: &fn(&T) -> bool);
|
||||
|
||||
/// Visit the values representing the symmetric difference
|
||||
fn symmetric_difference(&self, other: &Self, f: &fn(&T) -> bool);
|
||||
|
||||
/// Visit the values representing the intersection
|
||||
fn intersection(&self, other: &Self, f: &fn(&T) -> bool);
|
||||
|
||||
/// Visit the values representing the union
|
||||
fn union(&self, other: &Self, f: &fn(&T) -> bool);
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
pub trait Set<T>: Mutable {
|
||||
/// Return true if the set contains a value
|
||||
fn contains(&self, value: &T) -> bool;
|
||||
|
@ -171,11 +171,6 @@ unsafe fn _walk_safe_point(fp: *Word, sp: SafePoint, visitor: Visitor) -> bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
unsafe fn walk_safe_point(fp: *Word, sp: SafePoint, visitor: Visitor) {
|
||||
_walk_safe_point(fp, sp, visitor);
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
unsafe fn walk_safe_point(fp: *Word, sp: SafePoint, visitor: Visitor) -> bool {
|
||||
_walk_safe_point(fp, sp, visitor)
|
||||
}
|
||||
@ -303,11 +298,6 @@ unsafe fn _walk_gc_roots(mem: Memory, sentinel: **Word, visitor: Visitor) -> boo
|
||||
return true;
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
unsafe fn walk_gc_roots(mem: Memory, sentinel: **Word, visitor: Visitor) {
|
||||
_walk_gc_roots(mem, sentinel, visitor);
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
unsafe fn walk_gc_roots(mem: Memory, sentinel: **Word, visitor: Visitor) -> bool {
|
||||
_walk_gc_roots(mem, sentinel, visitor)
|
||||
}
|
||||
|
@ -19,8 +19,6 @@
|
||||
* CPRNG like rand::rng.
|
||||
*/
|
||||
|
||||
#[cfg(stage0)]
|
||||
use cast;
|
||||
use container::Container;
|
||||
use old_iter::BaseIter;
|
||||
use rt::io::Writer;
|
||||
@ -78,14 +76,6 @@ pub trait Streaming {
|
||||
fn reset(&mut self);
|
||||
}
|
||||
|
||||
// XXX: Ugly workaround for bootstrapping.
|
||||
#[cfg(stage0)]
|
||||
fn transmute_for_stage0<'a>(bytes: &'a [const u8]) -> &'a [u8] {
|
||||
unsafe {
|
||||
cast::transmute(bytes)
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
fn transmute_for_stage0<'a>(bytes: &'a [u8]) -> &'a [u8] {
|
||||
bytes
|
||||
}
|
||||
|
@ -87,22 +87,6 @@ priv impl<K:Hash + Eq,V> HashMap<K, V> {
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[cfg(stage0)]
|
||||
fn bucket_sequence(&self, hash: uint,
|
||||
op: &fn(uint) -> bool) {
|
||||
let start_idx = self.to_bucket(hash);
|
||||
let len_buckets = self.buckets.len();
|
||||
let mut idx = start_idx;
|
||||
loop {
|
||||
if !op(idx) { return; }
|
||||
idx = self.next_bucket(idx, len_buckets);
|
||||
if idx == start_idx {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
#[inline(always)]
|
||||
#[cfg(not(stage0))]
|
||||
fn bucket_sequence(&self, hash: uint,
|
||||
op: &fn(uint) -> bool) -> bool {
|
||||
let start_idx = self.to_bucket(hash);
|
||||
@ -318,19 +302,6 @@ impl<K:Hash + Eq,V> Map<K, V> for HashMap<K, V> {
|
||||
}
|
||||
|
||||
/// Visit all key-value pairs
|
||||
#[cfg(stage0)]
|
||||
fn each<'a>(&'a self, blk: &fn(&K, &'a V) -> bool) {
|
||||
for uint::range(0, self.buckets.len()) |i| {
|
||||
for self.buckets[i].each |bucket| {
|
||||
if !blk(&bucket.key, &bucket.value) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Visit all key-value pairs
|
||||
#[cfg(not(stage0))]
|
||||
fn each<'a>(&'a self, blk: &fn(&K, &'a V) -> bool) -> bool {
|
||||
for uint::range(0, self.buckets.len()) |i| {
|
||||
for self.buckets[i].each |bucket| {
|
||||
@ -343,44 +314,16 @@ impl<K:Hash + Eq,V> Map<K, V> for HashMap<K, V> {
|
||||
}
|
||||
|
||||
/// Visit all keys
|
||||
#[cfg(stage0)]
|
||||
fn each_key(&self, blk: &fn(k: &K) -> bool) {
|
||||
self.each(|k, _| blk(k))
|
||||
}
|
||||
|
||||
/// Visit all keys
|
||||
#[cfg(not(stage0))]
|
||||
fn each_key(&self, blk: &fn(k: &K) -> bool) -> bool {
|
||||
self.each(|k, _| blk(k))
|
||||
}
|
||||
|
||||
/// Visit all values
|
||||
#[cfg(stage0)]
|
||||
fn each_value<'a>(&'a self, blk: &fn(v: &'a V) -> bool) {
|
||||
self.each(|_, v| blk(v))
|
||||
}
|
||||
|
||||
/// Visit all values
|
||||
#[cfg(not(stage0))]
|
||||
fn each_value<'a>(&'a self, blk: &fn(v: &'a V) -> bool) -> bool {
|
||||
self.each(|_, v| blk(v))
|
||||
}
|
||||
|
||||
/// Iterate over the map and mutate the contained values
|
||||
#[cfg(stage0)]
|
||||
fn mutate_values(&mut self, blk: &fn(&K, &mut V) -> bool) {
|
||||
for uint::range(0, self.buckets.len()) |i| {
|
||||
match self.buckets[i] {
|
||||
Some(Bucket{key: ref key, value: ref mut value, _}) => {
|
||||
if !blk(key, value) { return }
|
||||
}
|
||||
None => ()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Iterate over the map and mutate the contained values
|
||||
#[cfg(not(stage0))]
|
||||
fn mutate_values(&mut self, blk: &fn(&K, &mut V) -> bool) -> bool {
|
||||
for uint::range(0, self.buckets.len()) |i| {
|
||||
match self.buckets[i] {
|
||||
@ -402,19 +345,6 @@ impl<K:Hash + Eq,V> Map<K, V> for HashMap<K, V> {
|
||||
}
|
||||
|
||||
/// Return a mutable reference to the value corresponding to the key
|
||||
#[cfg(stage0)]
|
||||
fn find_mut<'a>(&'a mut self, k: &K) -> Option<&'a mut V> {
|
||||
let idx = match self.bucket_for_key(k) {
|
||||
FoundEntry(idx) => idx,
|
||||
TableFull | FoundHole(_) => return None
|
||||
};
|
||||
unsafe {
|
||||
Some(::cast::transmute_mut_region(self.mut_value_for_bucket(idx)))
|
||||
}
|
||||
}
|
||||
|
||||
/// Return a mutable reference to the value corresponding to the key
|
||||
#[cfg(not(stage0))]
|
||||
fn find_mut<'a>(&'a mut self, k: &K) -> Option<&'a mut V> {
|
||||
let idx = match self.bucket_for_key(k) {
|
||||
FoundEntry(idx) => idx,
|
||||
@ -485,38 +415,6 @@ pub impl<K: Hash + Eq, V> HashMap<K, V> {
|
||||
|
||||
/// Return the value corresponding to the key in the map, or insert
|
||||
/// and return the value if it doesn't exist.
|
||||
#[cfg(stage0)]
|
||||
fn find_or_insert<'a>(&'a mut self, k: K, v: V) -> &'a V {
|
||||
if self.size >= self.resize_at {
|
||||
// n.b.: We could also do this after searching, so
|
||||
// that we do not resize if this call to insert is
|
||||
// simply going to update a key in place. My sense
|
||||
// though is that it's worse to have to search through
|
||||
// buckets to find the right spot twice than to just
|
||||
// resize in this corner case.
|
||||
self.expand();
|
||||
}
|
||||
|
||||
let hash = k.hash_keyed(self.k0, self.k1) as uint;
|
||||
let idx = match self.bucket_for_key_with_hash(hash, &k) {
|
||||
TableFull => fail!("Internal logic error"),
|
||||
FoundEntry(idx) => idx,
|
||||
FoundHole(idx) => {
|
||||
self.buckets[idx] = Some(Bucket{hash: hash, key: k,
|
||||
value: v});
|
||||
self.size += 1;
|
||||
idx
|
||||
},
|
||||
};
|
||||
|
||||
unsafe {
|
||||
::cast::transmute_region(self.value_for_bucket(idx))
|
||||
}
|
||||
}
|
||||
|
||||
/// Return the value corresponding to the key in the map, or insert
|
||||
/// and return the value if it doesn't exist.
|
||||
#[cfg(not(stage0))]
|
||||
fn find_or_insert<'a>(&'a mut self, k: K, v: V) -> &'a V {
|
||||
if self.size >= self.resize_at {
|
||||
// n.b.: We could also do this after searching, so
|
||||
@ -545,39 +443,6 @@ pub impl<K: Hash + Eq, V> HashMap<K, V> {
|
||||
|
||||
/// Return the value corresponding to the key in the map, or create,
|
||||
/// insert, and return a new value if it doesn't exist.
|
||||
#[cfg(stage0)]
|
||||
fn find_or_insert_with<'a>(&'a mut self, k: K, f: &fn(&K) -> V) -> &'a V {
|
||||
if self.size >= self.resize_at {
|
||||
// n.b.: We could also do this after searching, so
|
||||
// that we do not resize if this call to insert is
|
||||
// simply going to update a key in place. My sense
|
||||
// though is that it's worse to have to search through
|
||||
// buckets to find the right spot twice than to just
|
||||
// resize in this corner case.
|
||||
self.expand();
|
||||
}
|
||||
|
||||
let hash = k.hash_keyed(self.k0, self.k1) as uint;
|
||||
let idx = match self.bucket_for_key_with_hash(hash, &k) {
|
||||
TableFull => fail!("Internal logic error"),
|
||||
FoundEntry(idx) => idx,
|
||||
FoundHole(idx) => {
|
||||
let v = f(&k);
|
||||
self.buckets[idx] = Some(Bucket{hash: hash, key: k,
|
||||
value: v});
|
||||
self.size += 1;
|
||||
idx
|
||||
},
|
||||
};
|
||||
|
||||
unsafe {
|
||||
::cast::transmute_region(self.value_for_bucket(idx))
|
||||
}
|
||||
}
|
||||
|
||||
/// Return the value corresponding to the key in the map, or create,
|
||||
/// insert, and return a new value if it doesn't exist.
|
||||
#[cfg(not(stage0))]
|
||||
fn find_or_insert_with<'a>(&'a mut self, k: K, f: &fn(&K) -> V) -> &'a V {
|
||||
if self.size >= self.resize_at {
|
||||
// n.b.: We could also do this after searching, so
|
||||
@ -680,9 +545,6 @@ pub struct HashSet<T> {
|
||||
|
||||
impl<T:Hash + Eq> BaseIter<T> for HashSet<T> {
|
||||
/// Visit all values in order
|
||||
#[cfg(stage0)]
|
||||
fn each(&self, f: &fn(&T) -> bool) { self.map.each_key(f) }
|
||||
#[cfg(not(stage0))]
|
||||
fn each(&self, f: &fn(&T) -> bool) -> bool { self.map.each_key(f) }
|
||||
fn size_hint(&self) -> Option<uint> { Some(self.len()) }
|
||||
}
|
||||
@ -734,32 +596,11 @@ impl<T:Hash + Eq> Set<T> for HashSet<T> {
|
||||
}
|
||||
|
||||
/// Visit the values representing the difference
|
||||
#[cfg(stage0)]
|
||||
fn difference(&self, other: &HashSet<T>, f: &fn(&T) -> bool) {
|
||||
for self.each |v| {
|
||||
if !other.contains(v) {
|
||||
if !f(v) { return }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Visit the values representing the difference
|
||||
#[cfg(not(stage0))]
|
||||
fn difference(&self, other: &HashSet<T>, f: &fn(&T) -> bool) -> bool {
|
||||
self.each(|v| other.contains(v) || f(v))
|
||||
}
|
||||
|
||||
/// Visit the values representing the symmetric difference
|
||||
#[cfg(stage0)]
|
||||
fn symmetric_difference(&self,
|
||||
other: &HashSet<T>,
|
||||
f: &fn(&T) -> bool) {
|
||||
self.difference(other, f);
|
||||
other.difference(self, f);
|
||||
}
|
||||
|
||||
/// Visit the values representing the symmetric difference
|
||||
#[cfg(not(stage0))]
|
||||
fn symmetric_difference(&self,
|
||||
other: &HashSet<T>,
|
||||
f: &fn(&T) -> bool) -> bool {
|
||||
@ -767,37 +608,11 @@ impl<T:Hash + Eq> Set<T> for HashSet<T> {
|
||||
}
|
||||
|
||||
/// Visit the values representing the intersection
|
||||
#[cfg(stage0)]
|
||||
fn intersection(&self, other: &HashSet<T>, f: &fn(&T) -> bool) {
|
||||
for self.each |v| {
|
||||
if other.contains(v) {
|
||||
if !f(v) { return }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Visit the values representing the intersection
|
||||
#[cfg(not(stage0))]
|
||||
fn intersection(&self, other: &HashSet<T>, f: &fn(&T) -> bool) -> bool {
|
||||
self.each(|v| !other.contains(v) || f(v))
|
||||
}
|
||||
|
||||
/// Visit the values representing the union
|
||||
#[cfg(stage0)]
|
||||
fn union(&self, other: &HashSet<T>, f: &fn(&T) -> bool) {
|
||||
for self.each |v| {
|
||||
if !f(v) { return }
|
||||
}
|
||||
|
||||
for other.each |v| {
|
||||
if !self.contains(v) {
|
||||
if !f(v) { return }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Visit the values representing the union
|
||||
#[cfg(not(stage0))]
|
||||
fn union(&self, other: &HashSet<T>, f: &fn(&T) -> bool) -> bool {
|
||||
self.each(f) && other.each(|v| self.contains(v) || f(v))
|
||||
}
|
||||
|
@ -292,9 +292,6 @@ pub trait ReaderUtil {
|
||||
*
|
||||
* None right now.
|
||||
*/
|
||||
#[cfg(stage0)]
|
||||
fn each_byte(&self, it: &fn(int) -> bool);
|
||||
#[cfg(not(stage0))]
|
||||
fn each_byte(&self, it: &fn(int) -> bool) -> bool;
|
||||
|
||||
/**
|
||||
@ -304,9 +301,6 @@ pub trait ReaderUtil {
|
||||
*
|
||||
* None right now.
|
||||
*/
|
||||
#[cfg(stage0)]
|
||||
fn each_char(&self, it: &fn(char) -> bool);
|
||||
#[cfg(not(stage0))]
|
||||
fn each_char(&self, it: &fn(char) -> bool) -> bool;
|
||||
|
||||
/**
|
||||
@ -316,9 +310,6 @@ pub trait ReaderUtil {
|
||||
*
|
||||
* None right now.
|
||||
*/
|
||||
#[cfg(stage0)]
|
||||
fn each_line(&self, it: &fn(&str) -> bool);
|
||||
#[cfg(not(stage0))]
|
||||
fn each_line(&self, it: &fn(&str) -> bool) -> bool;
|
||||
|
||||
/**
|
||||
@ -730,13 +721,6 @@ impl<T:Reader> ReaderUtil for T {
|
||||
bytes
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
fn each_byte(&self, it: &fn(int) -> bool) {
|
||||
while !self.eof() {
|
||||
if !it(self.read_byte()) { break; }
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
fn each_byte(&self, it: &fn(int) -> bool) -> bool {
|
||||
while !self.eof() {
|
||||
if !it(self.read_byte()) { return false; }
|
||||
@ -744,13 +728,6 @@ impl<T:Reader> ReaderUtil for T {
|
||||
return true;
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
fn each_char(&self, it: &fn(char) -> bool) {
|
||||
while !self.eof() {
|
||||
if !it(self.read_char()) { break; }
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
fn each_char(&self, it: &fn(char) -> bool) -> bool {
|
||||
while !self.eof() {
|
||||
if !it(self.read_char()) { return false; }
|
||||
@ -758,27 +735,6 @@ impl<T:Reader> ReaderUtil for T {
|
||||
return true;
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
fn each_line(&self, it: &fn(s: &str) -> bool) {
|
||||
while !self.eof() {
|
||||
// include the \n, so that we can distinguish an entirely empty
|
||||
// line read after "...\n", and the trailing empty line in
|
||||
// "...\n\n".
|
||||
let mut line = self.read_until('\n' as u8, true);
|
||||
|
||||
// blank line at the end of the reader is ignored
|
||||
if self.eof() && line.is_empty() { break; }
|
||||
|
||||
// trim the \n, so that each_line is consistent with read_line
|
||||
let n = str::len(line);
|
||||
if line[n-1] == '\n' as u8 {
|
||||
unsafe { str::raw::set_len(&mut line, n-1); }
|
||||
}
|
||||
|
||||
if !it(line) { break; }
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
fn each_line(&self, it: &fn(s: &str) -> bool) -> bool {
|
||||
while !self.eof() {
|
||||
// include the \n, so that we can distinguish an entirely empty
|
||||
|
@ -40,17 +40,12 @@ much easier to implement.
|
||||
|
||||
*/
|
||||
|
||||
#[cfg(not(stage0))] use cmp::Ord;
|
||||
#[cfg(not(stage0))] use option::{Option, Some, None};
|
||||
#[cfg(not(stage0))] use vec::OwnedVector;
|
||||
#[cfg(not(stage0))] use num::{One, Zero};
|
||||
#[cfg(not(stage0))] use ops::{Add, Mul};
|
||||
use cmp::Ord;
|
||||
use option::{Option, Some, None};
|
||||
use vec::OwnedVector;
|
||||
use num::{One, Zero};
|
||||
use ops::{Add, Mul};
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub trait Times {
|
||||
fn times(&self, it: &fn() -> bool);
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
pub trait Times {
|
||||
fn times(&self, it: &fn() -> bool) -> bool;
|
||||
}
|
||||
@ -67,7 +62,6 @@ pub trait Times {
|
||||
* ~~~
|
||||
*/
|
||||
#[inline(always)]
|
||||
#[cfg(not(stage0))]
|
||||
pub fn to_vec<T>(iter: &fn(f: &fn(T) -> bool) -> bool) -> ~[T] {
|
||||
let mut v = ~[];
|
||||
for iter |x| { v.push(x) }
|
||||
@ -86,7 +80,6 @@ pub fn to_vec<T>(iter: &fn(f: &fn(T) -> bool) -> bool) -> ~[T] {
|
||||
* ~~~~
|
||||
*/
|
||||
#[inline(always)]
|
||||
#[cfg(not(stage0))]
|
||||
pub fn any<T>(predicate: &fn(T) -> bool,
|
||||
iter: &fn(f: &fn(T) -> bool) -> bool) -> bool {
|
||||
for iter |x| {
|
||||
@ -108,29 +101,6 @@ pub fn any<T>(predicate: &fn(T) -> bool,
|
||||
* ~~~~
|
||||
*/
|
||||
#[inline(always)]
|
||||
#[cfg(stage0)]
|
||||
pub fn all<T>(predicate: &fn(T) -> bool,
|
||||
iter: &fn(f: &fn(T) -> bool)) -> bool {
|
||||
for iter |x| {
|
||||
if !predicate(x) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if `predicate` is true for all values yielded by an internal iterator.
|
||||
*
|
||||
* # Example:
|
||||
*
|
||||
* ~~~~
|
||||
* assert!(all(|&x: &uint| x < 6, |f| uint::range(1, 6, f)));
|
||||
* assert!(!all(|&x: &uint| x < 5, |f| uint::range(1, 6, f)));
|
||||
* ~~~~
|
||||
*/
|
||||
#[inline(always)]
|
||||
#[cfg(not(stage0))]
|
||||
pub fn all<T>(predicate: &fn(T) -> bool,
|
||||
iter: &fn(f: &fn(T) -> bool) -> bool) -> bool {
|
||||
// If we ever break, iter will return false, so this will only return true
|
||||
@ -149,7 +119,6 @@ pub fn all<T>(predicate: &fn(T) -> bool,
|
||||
* ~~~~
|
||||
*/
|
||||
#[inline(always)]
|
||||
#[cfg(not(stage0))]
|
||||
pub fn find<T>(predicate: &fn(&T) -> bool,
|
||||
iter: &fn(f: &fn(T) -> bool) -> bool) -> Option<T> {
|
||||
for iter |x| {
|
||||
@ -171,7 +140,6 @@ pub fn find<T>(predicate: &fn(&T) -> bool,
|
||||
* ~~~~
|
||||
*/
|
||||
#[inline]
|
||||
#[cfg(not(stage0))]
|
||||
pub fn max<T: Ord>(iter: &fn(f: &fn(T) -> bool) -> bool) -> Option<T> {
|
||||
let mut result = None;
|
||||
for iter |x| {
|
||||
@ -198,7 +166,6 @@ pub fn max<T: Ord>(iter: &fn(f: &fn(T) -> bool) -> bool) -> Option<T> {
|
||||
* ~~~~
|
||||
*/
|
||||
#[inline]
|
||||
#[cfg(not(stage0))]
|
||||
pub fn min<T: Ord>(iter: &fn(f: &fn(T) -> bool) -> bool) -> Option<T> {
|
||||
let mut result = None;
|
||||
for iter |x| {
|
||||
@ -223,7 +190,6 @@ pub fn min<T: Ord>(iter: &fn(f: &fn(T) -> bool) -> bool) -> Option<T> {
|
||||
* assert_eq!(fold(0i, |f| int::range(1, 5, f), |a, x| *a += x), 10);
|
||||
* ~~~~
|
||||
*/
|
||||
#[cfg(not(stage0))]
|
||||
#[inline]
|
||||
pub fn fold<T, U>(start: T, iter: &fn(f: &fn(U) -> bool) -> bool, f: &fn(&mut T, U)) -> T {
|
||||
let mut result = start;
|
||||
@ -247,7 +213,6 @@ pub fn fold<T, U>(start: T, iter: &fn(f: &fn(U) -> bool) -> bool, f: &fn(&mut T,
|
||||
* }
|
||||
* ~~~~
|
||||
*/
|
||||
#[cfg(not(stage0))]
|
||||
#[inline]
|
||||
pub fn fold_ref<T, U>(start: T, iter: &fn(f: &fn(&U) -> bool) -> bool, f: &fn(&mut T, &U)) -> T {
|
||||
let mut result = start;
|
||||
@ -267,7 +232,6 @@ pub fn fold_ref<T, U>(start: T, iter: &fn(f: &fn(&U) -> bool) -> bool, f: &fn(&m
|
||||
* assert_eq!(do sum |f| { xs.each(f) }, 10);
|
||||
* ~~~~
|
||||
*/
|
||||
#[cfg(not(stage0))]
|
||||
#[inline(always)]
|
||||
pub fn sum<T: Zero + Add<T, T>>(iter: &fn(f: &fn(&T) -> bool) -> bool) -> T {
|
||||
fold_ref(Zero::zero::<T>(), iter, |a, x| *a = a.add(x))
|
||||
@ -283,7 +247,6 @@ pub fn sum<T: Zero + Add<T, T>>(iter: &fn(f: &fn(&T) -> bool) -> bool) -> T {
|
||||
* assert_eq!(do product |f| { xs.each(f) }, 24);
|
||||
* ~~~~
|
||||
*/
|
||||
#[cfg(not(stage0))]
|
||||
#[inline(always)]
|
||||
pub fn product<T: One + Mul<T, T>>(iter: &fn(f: &fn(&T) -> bool) -> bool) -> T {
|
||||
fold_ref(One::one::<T>(), iter, |a, x| *a = a.mul(x))
|
||||
|
@ -43,11 +43,7 @@ pub trait IteratorUtil<A> {
|
||||
fn take(self, n: uint) -> TakeIterator<Self>;
|
||||
fn scan<'r, St, B>(self, initial_state: St, f: &'r fn(&mut St, A) -> Option<B>)
|
||||
-> ScanIterator<'r, A, B, Self, St>;
|
||||
#[cfg(stage0)]
|
||||
fn advance(&mut self, f: &fn(A) -> bool);
|
||||
#[cfg(not(stage0))]
|
||||
fn advance(&mut self, f: &fn(A) -> bool) -> bool;
|
||||
#[cfg(not(stage0))]
|
||||
fn to_vec(&mut self) -> ~[A];
|
||||
fn nth(&mut self, n: uint) -> Option<A>;
|
||||
fn last(&mut self) -> Option<A>;
|
||||
@ -121,21 +117,6 @@ impl<A, T: Iterator<A>> IteratorUtil<A> for T {
|
||||
|
||||
/// A shim implementing the `for` loop iteration protocol for iterator objects
|
||||
#[inline]
|
||||
#[cfg(stage0)]
|
||||
fn advance(&mut self, f: &fn(A) -> bool) {
|
||||
loop {
|
||||
match self.next() {
|
||||
Some(x) => {
|
||||
if !f(x) { return; }
|
||||
}
|
||||
None => { return; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A shim implementing the `for` loop iteration protocol for iterator objects
|
||||
#[inline]
|
||||
#[cfg(not(stage0))]
|
||||
fn advance(&mut self, f: &fn(A) -> bool) -> bool {
|
||||
loop {
|
||||
match self.next() {
|
||||
@ -147,7 +128,6 @@ impl<A, T: Iterator<A>> IteratorUtil<A> for T {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
#[inline(always)]
|
||||
fn to_vec(&mut self) -> ~[A] {
|
||||
iter::to_vec::<A>(|f| self.advance(f))
|
||||
|
@ -51,9 +51,3 @@ pub trait Owned {
|
||||
pub trait Const {
|
||||
// Empty.
|
||||
}
|
||||
|
||||
#[lang="durable"]
|
||||
#[cfg(stage0)]
|
||||
pub trait Durable {
|
||||
// Empty.
|
||||
}
|
||||
|
@ -248,18 +248,8 @@ impl Orderable for f32 {
|
||||
if self.is_NaN() || other.is_NaN() { Float::NaN() } else { fmax(*self, *other) }
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
#[inline(always)]
|
||||
fn clamp(&self, mn: &f32, mx: &f32) -> f32 {
|
||||
if self.is_NaN() { *self }
|
||||
else if !(*self <= *mx) { *mx }
|
||||
else if !(*self >= *mn) { *mn }
|
||||
else { *self }
|
||||
}
|
||||
|
||||
/// Returns the number constrained within the range `mn <= self <= mx`.
|
||||
/// If any of the numbers are `NaN` then `NaN` is returned.
|
||||
#[cfg(not(stage0))]
|
||||
#[inline(always)]
|
||||
fn clamp(&self, mn: &f32, mx: &f32) -> f32 {
|
||||
cond!(
|
||||
|
@ -270,18 +270,8 @@ impl Orderable for f64 {
|
||||
if self.is_NaN() || other.is_NaN() { Float::NaN() } else { fmax(*self, *other) }
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
#[inline(always)]
|
||||
fn clamp(&self, mn: &f64, mx: &f64) -> f64 {
|
||||
if self.is_NaN() { *self }
|
||||
else if !(*self <= *mx) { *mx }
|
||||
else if !(*self >= *mn) { *mn }
|
||||
else { *self }
|
||||
}
|
||||
|
||||
/// Returns the number constrained within the range `mn <= self <= mx`.
|
||||
/// If any of the numbers are `NaN` then `NaN` is returned.
|
||||
#[cfg(not(stage0))]
|
||||
#[inline(always)]
|
||||
fn clamp(&self, mn: &f64, mx: &f64) -> f64 {
|
||||
cond!(
|
||||
|
@ -108,37 +108,17 @@ pub fn _range_step(start: T, stop: T, step: T, it: &fn(T) -> bool) -> bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub fn range_step(start: T, stop: T, step: T, it: &fn(T) -> bool) {
|
||||
_range_step(start, stop, step, it);
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
pub fn range_step(start: T, stop: T, step: T, it: &fn(T) -> bool) -> bool {
|
||||
_range_step(start, stop, step, it)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[cfg(stage0)]
|
||||
/// Iterate over the range [`lo`..`hi`)
|
||||
pub fn range(lo: T, hi: T, it: &fn(T) -> bool) {
|
||||
range_step(lo, hi, 1 as T, it);
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[cfg(not(stage0))]
|
||||
/// Iterate over the range [`lo`..`hi`)
|
||||
pub fn range(lo: T, hi: T, it: &fn(T) -> bool) -> bool {
|
||||
range_step(lo, hi, 1 as T, it)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[cfg(stage0)]
|
||||
/// Iterate over the range [`hi`..`lo`)
|
||||
pub fn range_rev(hi: T, lo: T, it: &fn(T) -> bool) {
|
||||
range_step(hi, lo, -1 as T, it);
|
||||
}
|
||||
#[inline(always)]
|
||||
#[cfg(not(stage0))]
|
||||
/// Iterate over the range [`hi`..`lo`)
|
||||
pub fn range_rev(hi: T, lo: T, it: &fn(T) -> bool) -> bool {
|
||||
range_step(hi, lo, -1 as T, it)
|
||||
@ -187,15 +167,7 @@ impl Orderable for T {
|
||||
if *self > *other { *self } else { *other }
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
#[inline(always)]
|
||||
fn clamp(&self, mn: &T, mx: &T) -> T {
|
||||
if *self > *mx { *mx } else
|
||||
if *self < *mn { *mn } else { *self }
|
||||
}
|
||||
|
||||
/// Returns the number constrained within the range `mn <= self <= mx`.
|
||||
#[cfg(not(stage0))]
|
||||
#[inline(always)]
|
||||
fn clamp(&self, mn: &T, mx: &T) -> T {
|
||||
cond!(
|
||||
|
@ -77,38 +77,17 @@ pub fn _range_step(start: T,
|
||||
return true;
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub fn range_step(start: T, stop: T, step: T_SIGNED, it: &fn(T) -> bool) {
|
||||
_range_step(start, stop, step, it);
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
pub fn range_step(start: T, stop: T, step: T_SIGNED, it: &fn(T) -> bool) -> bool {
|
||||
_range_step(start, stop, step, it)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[cfg(stage0)]
|
||||
/// Iterate over the range [`lo`..`hi`)
|
||||
pub fn range(lo: T, hi: T, it: &fn(T) -> bool) {
|
||||
range_step(lo, hi, 1 as T_SIGNED, it);
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[cfg(not(stage0))]
|
||||
/// Iterate over the range [`lo`..`hi`)
|
||||
pub fn range(lo: T, hi: T, it: &fn(T) -> bool) -> bool {
|
||||
range_step(lo, hi, 1 as T_SIGNED, it)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[cfg(stage0)]
|
||||
/// Iterate over the range [`hi`..`lo`)
|
||||
pub fn range_rev(hi: T, lo: T, it: &fn(T) -> bool) {
|
||||
range_step(hi, lo, -1 as T_SIGNED, it);
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[cfg(not(stage0))]
|
||||
/// Iterate over the range [`hi`..`lo`)
|
||||
pub fn range_rev(hi: T, lo: T, it: &fn(T) -> bool) -> bool {
|
||||
range_step(hi, lo, -1 as T_SIGNED, it)
|
||||
@ -153,15 +132,7 @@ impl Orderable for T {
|
||||
if *self > *other { *self } else { *other }
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
#[inline(always)]
|
||||
fn clamp(&self, mn: &T, mx: &T) -> T {
|
||||
if *self > *mx { *mx } else
|
||||
if *self < *mn { *mn } else { *self }
|
||||
}
|
||||
|
||||
/// Returns the number constrained within the range `mn <= self <= mx`.
|
||||
#[cfg(not(stage0))]
|
||||
#[inline(always)]
|
||||
fn clamp(&self, mn: &T, mx: &T) -> T {
|
||||
cond!(
|
||||
|
@ -154,29 +154,6 @@ pub mod inst {
|
||||
return true;
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl iter::Times for uint {
|
||||
#[inline(always)]
|
||||
///
|
||||
/// A convenience form for basic iteration. Given a uint `x`,
|
||||
/// `for x.times { ... }` executes the given block x times.
|
||||
///
|
||||
/// Equivalent to `for uint::range(0, x) |_| { ... }`.
|
||||
///
|
||||
/// Not defined on all integer types to permit unambiguous
|
||||
/// use with integer literals of inferred integer-type as
|
||||
/// the self-value (eg. `for 100.times { ... }`).
|
||||
///
|
||||
fn times(&self, it: &fn() -> bool) {
|
||||
let mut i = *self;
|
||||
while i > 0 {
|
||||
if !it() { break }
|
||||
i -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
impl iter::Times for uint {
|
||||
#[inline(always)]
|
||||
///
|
||||
|
@ -22,39 +22,20 @@ use vec;
|
||||
/// A function used to initialize the elements of a sequence
|
||||
pub type InitOp<'self,T> = &'self fn(uint) -> T;
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub trait BaseIter<A> {
|
||||
fn each(&self, blk: &fn(v: &A) -> bool);
|
||||
fn size_hint(&self) -> Option<uint>;
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
pub trait BaseIter<A> {
|
||||
fn each(&self, blk: &fn(v: &A) -> bool) -> bool;
|
||||
fn size_hint(&self) -> Option<uint>;
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub trait ReverseIter<A>: BaseIter<A> {
|
||||
fn each_reverse(&self, blk: &fn(&A) -> bool);
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
pub trait ReverseIter<A>: BaseIter<A> {
|
||||
fn each_reverse(&self, blk: &fn(&A) -> bool) -> bool;
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub trait MutableIter<A>: BaseIter<A> {
|
||||
fn each_mut(&mut self, blk: &fn(&mut A) -> bool);
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
pub trait MutableIter<A>: BaseIter<A> {
|
||||
fn each_mut(&mut self, blk: &fn(&mut A) -> bool) -> bool;
|
||||
}
|
||||
|
||||
pub trait ExtendedIter<A> {
|
||||
#[cfg(stage0)]
|
||||
fn eachi(&self, blk: &fn(uint, v: &A) -> bool);
|
||||
#[cfg(not(stage0))]
|
||||
fn eachi(&self, blk: &fn(uint, v: &A) -> bool) -> bool;
|
||||
fn all(&self, blk: &fn(&A) -> bool) -> bool;
|
||||
fn any(&self, blk: &fn(&A) -> bool) -> bool;
|
||||
@ -64,11 +45,6 @@ pub trait ExtendedIter<A> {
|
||||
fn flat_map_to_vec<B,IB: BaseIter<B>>(&self, op: &fn(&A) -> IB) -> ~[B];
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub trait ExtendedMutableIter<A> {
|
||||
fn eachi_mut(&mut self, blk: &fn(uint, &mut A) -> bool);
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
pub trait ExtendedMutableIter<A> {
|
||||
fn eachi_mut(&mut self, blk: &fn(uint, &mut A) -> bool) -> bool;
|
||||
}
|
||||
@ -127,11 +103,6 @@ pub fn _eachi<A,IA:BaseIter<A>>(this: &IA, blk: &fn(uint, &A) -> bool) -> bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub fn eachi<A,IA:BaseIter<A>>(this: &IA, blk: &fn(uint, &A) -> bool) {
|
||||
_eachi(this, blk);
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
pub fn eachi<A,IA:BaseIter<A>>(this: &IA, blk: &fn(uint, &A) -> bool) -> bool {
|
||||
_eachi(this, blk)
|
||||
}
|
||||
|
@ -112,13 +112,6 @@ impl<T: Copy + Add<T,T>> Add<Option<T>, Option<T>> for Option<T> {
|
||||
impl<T> BaseIter<T> for Option<T> {
|
||||
/// Performs an operation on the contained value by reference
|
||||
#[inline(always)]
|
||||
#[cfg(stage0)]
|
||||
fn each<'a>(&'a self, f: &fn(x: &'a T) -> bool) {
|
||||
match *self { None => (), Some(ref t) => { f(t); } }
|
||||
}
|
||||
/// Performs an operation on the contained value by reference
|
||||
#[inline(always)]
|
||||
#[cfg(not(stage0))]
|
||||
fn each<'a>(&'a self, f: &fn(x: &'a T) -> bool) -> bool {
|
||||
match *self { None => true, Some(ref t) => { f(t) } }
|
||||
}
|
||||
@ -130,12 +123,6 @@ impl<T> BaseIter<T> for Option<T> {
|
||||
}
|
||||
|
||||
impl<T> MutableIter<T> for Option<T> {
|
||||
#[cfg(stage0)]
|
||||
#[inline(always)]
|
||||
fn each_mut<'a>(&'a mut self, f: &fn(&'a mut T) -> bool) {
|
||||
match *self { None => (), Some(ref mut t) => { f(t); } }
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
#[inline(always)]
|
||||
fn each_mut<'a>(&'a mut self, f: &fn(&'a mut T) -> bool) -> bool {
|
||||
match *self { None => true, Some(ref mut t) => { f(t) } }
|
||||
@ -143,11 +130,6 @@ impl<T> MutableIter<T> for Option<T> {
|
||||
}
|
||||
|
||||
impl<A> ExtendedIter<A> for Option<A> {
|
||||
#[cfg(stage0)]
|
||||
pub fn eachi(&self, blk: &fn(uint, v: &A) -> bool) {
|
||||
old_iter::eachi(self, blk)
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
pub fn eachi(&self, blk: &fn(uint, v: &A) -> bool) -> bool {
|
||||
old_iter::eachi(self, blk)
|
||||
}
|
||||
|
@ -575,37 +575,8 @@ pub fn tmpdir() -> Path {
|
||||
getenv_nonempty("WINDIR")))).get_or_default(Path("C:\\Windows"))
|
||||
}
|
||||
}
|
||||
/// Recursively walk a directory structure
|
||||
#[cfg(stage0)]
|
||||
pub fn walk_dir(p: &Path, f: &fn(&Path) -> bool) {
|
||||
|
||||
walk_dir_(p, f);
|
||||
|
||||
fn walk_dir_(p: &Path, f: &fn(&Path) -> bool) -> bool {
|
||||
let mut keepgoing = true;
|
||||
do list_dir(p).each |q| {
|
||||
let path = &p.push(*q);
|
||||
if !f(path) {
|
||||
keepgoing = false;
|
||||
false
|
||||
} else {
|
||||
if path_is_dir(path) {
|
||||
if !walk_dir_(path, f) {
|
||||
keepgoing = false;
|
||||
false
|
||||
} else {
|
||||
true
|
||||
}
|
||||
} else {
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
return keepgoing;
|
||||
}
|
||||
}
|
||||
/// Recursively walk a directory structure
|
||||
#[cfg(not(stage0))]
|
||||
pub fn walk_dir(p: &Path, f: &fn(&Path) -> bool) -> bool {
|
||||
list_dir(p).each(|q| {
|
||||
let path = &p.push(*q);
|
||||
|
@ -22,9 +22,6 @@ use ops::Drop;
|
||||
use kinds::Owned;
|
||||
use rt::sched::Coroutine;
|
||||
use rt::local_sched;
|
||||
#[cfg(stage0)]
|
||||
use unstable::intrinsics::{atomic_xchg};
|
||||
#[cfg(not(stage0))]
|
||||
use unstable::intrinsics::{atomic_xchg, atomic_load};
|
||||
use util::Void;
|
||||
use comm::{GenericChan, GenericSmartChan, GenericPort, Peekable};
|
||||
@ -210,10 +207,6 @@ impl<T> PortOne<T> {
|
||||
}
|
||||
|
||||
impl<T> Peekable<T> for PortOne<T> {
|
||||
#[cfg(stage0)]
|
||||
fn peek(&self) -> bool { fail!() }
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
fn peek(&self) -> bool {
|
||||
unsafe {
|
||||
let packet: *mut Packet<T> = self.inner.packet();
|
||||
|
@ -253,18 +253,13 @@ pub use self::stdio::println;
|
||||
|
||||
pub use self::file::FileStream;
|
||||
pub use self::net::ip::IpAddr;
|
||||
#[cfg(not(stage0))]
|
||||
pub use self::net::tcp::TcpListener;
|
||||
#[cfg(not(stage0))]
|
||||
pub use self::net::tcp::TcpStream;
|
||||
pub use self::net::udp::UdpStream;
|
||||
|
||||
// Some extension traits that all Readers and Writers get.
|
||||
#[cfg(not(stage0))] // Requires condition! fixes
|
||||
pub use self::extensions::ReaderUtil;
|
||||
#[cfg(not(stage0))] // Requires condition! fixes
|
||||
pub use self::extensions::ReaderByteConversions;
|
||||
#[cfg(not(stage0))] // Requires condition! fixes
|
||||
pub use self::extensions::WriterByteConversions;
|
||||
|
||||
/// Synchronous, non-blocking file I/O.
|
||||
@ -272,7 +267,6 @@ pub mod file;
|
||||
|
||||
/// Synchronous, non-blocking network I/O.
|
||||
pub mod net {
|
||||
#[cfg(not(stage0))]
|
||||
pub mod tcp;
|
||||
pub mod udp;
|
||||
pub mod ip;
|
||||
@ -288,7 +282,6 @@ pub mod mem;
|
||||
pub mod stdio;
|
||||
|
||||
/// Implementations for Option
|
||||
#[cfg(not(stage0))] // Requires condition! fixes
|
||||
mod option;
|
||||
|
||||
/// Basic stream compression. XXX: Belongs with other flate code
|
||||
@ -298,7 +291,6 @@ pub mod flate;
|
||||
pub mod comm_adapters;
|
||||
|
||||
/// Extension traits
|
||||
#[cfg(not(stage0))] // Requires condition! fixes
|
||||
mod extensions;
|
||||
|
||||
/// Non-I/O things needed by the I/O module
|
||||
|
@ -24,35 +24,6 @@ pub fn Frame(fp: *Word) -> Frame {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub fn walk_stack(visit: &fn(Frame) -> bool) {
|
||||
|
||||
debug!("beginning stack walk");
|
||||
|
||||
do frame_address |frame_pointer| {
|
||||
let mut frame_address: *Word = unsafe {
|
||||
transmute(frame_pointer)
|
||||
};
|
||||
loop {
|
||||
let fr = Frame(frame_address);
|
||||
|
||||
debug!("frame: %x", unsafe { transmute(fr.fp) });
|
||||
visit(fr);
|
||||
|
||||
unsafe {
|
||||
let next_fp: **Word = transmute(frame_address);
|
||||
frame_address = *next_fp;
|
||||
if *frame_address == 0u {
|
||||
debug!("encountered task_start_wrapper. ending walk");
|
||||
// This is the task_start_wrapper_frame. There is
|
||||
// no stack beneath it and it is a foreign frame.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
pub fn walk_stack(visit: &fn(Frame) -> bool) -> bool {
|
||||
|
||||
debug!("beginning stack walk");
|
||||
|
@ -557,27 +557,12 @@ pub fn slice<'a>(s: &'a str, begin: uint, end: uint) -> &'a str {
|
||||
}
|
||||
|
||||
/// Splits a string into substrings at each occurrence of a given character
|
||||
#[cfg(stage0)]
|
||||
pub fn each_split_char<'a>(s: &'a str, sep: char, it: &fn(&'a str) -> bool) {
|
||||
each_split_char_inner(s, sep, len(s), true, true, it);
|
||||
}
|
||||
|
||||
/// Splits a string into substrings at each occurrence of a given character
|
||||
#[cfg(not(stage0))]
|
||||
pub fn each_split_char<'a>(s: &'a str, sep: char,
|
||||
it: &fn(&'a str) -> bool) -> bool {
|
||||
each_split_char_inner(s, sep, len(s), true, true, it)
|
||||
}
|
||||
|
||||
/// Like `each_split_char`, but a trailing empty string is omitted
|
||||
#[cfg(stage0)]
|
||||
pub fn each_split_char_no_trailing<'a>(s: &'a str,
|
||||
sep: char,
|
||||
it: &fn(&'a str) -> bool) {
|
||||
each_split_char_inner(s, sep, len(s), true, false, it);
|
||||
}
|
||||
/// Like `each_split_char`, but a trailing empty string is omitted
|
||||
#[cfg(not(stage0))]
|
||||
pub fn each_split_char_no_trailing<'a>(s: &'a str,
|
||||
sep: char,
|
||||
it: &fn(&'a str) -> bool) -> bool {
|
||||
@ -590,20 +575,6 @@ pub fn each_split_char_no_trailing<'a>(s: &'a str,
|
||||
*
|
||||
* The character must be a valid UTF-8/ASCII character
|
||||
*/
|
||||
#[cfg(stage0)]
|
||||
pub fn each_splitn_char<'a>(s: &'a str,
|
||||
sep: char,
|
||||
count: uint,
|
||||
it: &fn(&'a str) -> bool) {
|
||||
each_split_char_inner(s, sep, count, true, true, it);
|
||||
}
|
||||
/**
|
||||
* Splits a string into substrings at each occurrence of a given
|
||||
* character up to 'count' times.
|
||||
*
|
||||
* The character must be a valid UTF-8/ASCII character
|
||||
*/
|
||||
#[cfg(not(stage0))]
|
||||
pub fn each_splitn_char<'a>(s: &'a str,
|
||||
sep: char,
|
||||
count: uint,
|
||||
@ -612,14 +583,6 @@ pub fn each_splitn_char<'a>(s: &'a str,
|
||||
}
|
||||
|
||||
/// Like `each_split_char`, but omits empty strings
|
||||
#[cfg(stage0)]
|
||||
pub fn each_split_char_nonempty<'a>(s: &'a str,
|
||||
sep: char,
|
||||
it: &fn(&'a str) -> bool) {
|
||||
each_split_char_inner(s, sep, len(s), false, false, it);
|
||||
}
|
||||
/// Like `each_split_char`, but omits empty strings
|
||||
#[cfg(not(stage0))]
|
||||
pub fn each_split_char_nonempty<'a>(s: &'a str,
|
||||
sep: char,
|
||||
it: &fn(&'a str) -> bool) -> bool {
|
||||
@ -659,14 +622,6 @@ fn each_split_char_inner<'a>(s: &'a str,
|
||||
}
|
||||
|
||||
/// Splits a string into substrings using a character function
|
||||
#[cfg(stage0)]
|
||||
pub fn each_split<'a>(s: &'a str,
|
||||
sepfn: &fn(char) -> bool,
|
||||
it: &fn(&'a str) -> bool) {
|
||||
each_split_inner(s, sepfn, len(s), true, true, it);
|
||||
}
|
||||
/// Splits a string into substrings using a character function
|
||||
#[cfg(not(stage0))]
|
||||
pub fn each_split<'a>(s: &'a str,
|
||||
sepfn: &fn(char) -> bool,
|
||||
it: &fn(&'a str) -> bool) -> bool {
|
||||
@ -674,14 +629,6 @@ pub fn each_split<'a>(s: &'a str,
|
||||
}
|
||||
|
||||
/// Like `each_split`, but a trailing empty string is omitted
|
||||
#[cfg(stage0)]
|
||||
pub fn each_split_no_trailing<'a>(s: &'a str,
|
||||
sepfn: &fn(char) -> bool,
|
||||
it: &fn(&'a str) -> bool) {
|
||||
each_split_inner(s, sepfn, len(s), true, false, it);
|
||||
}
|
||||
/// Like `each_split`, but a trailing empty string is omitted
|
||||
#[cfg(not(stage0))]
|
||||
pub fn each_split_no_trailing<'a>(s: &'a str,
|
||||
sepfn: &fn(char) -> bool,
|
||||
it: &fn(&'a str) -> bool) -> bool {
|
||||
@ -692,18 +639,6 @@ pub fn each_split_no_trailing<'a>(s: &'a str,
|
||||
* Splits a string into substrings using a character function, cutting at
|
||||
* most `count` times.
|
||||
*/
|
||||
#[cfg(stage0)]
|
||||
pub fn each_splitn<'a>(s: &'a str,
|
||||
sepfn: &fn(char) -> bool,
|
||||
count: uint,
|
||||
it: &fn(&'a str) -> bool) {
|
||||
each_split_inner(s, sepfn, count, true, true, it);
|
||||
}
|
||||
/**
|
||||
* Splits a string into substrings using a character function, cutting at
|
||||
* most `count` times.
|
||||
*/
|
||||
#[cfg(not(stage0))]
|
||||
pub fn each_splitn<'a>(s: &'a str,
|
||||
sepfn: &fn(char) -> bool,
|
||||
count: uint,
|
||||
@ -712,14 +647,6 @@ pub fn each_splitn<'a>(s: &'a str,
|
||||
}
|
||||
|
||||
/// Like `each_split`, but omits empty strings
|
||||
#[cfg(stage0)]
|
||||
pub fn each_split_nonempty<'a>(s: &'a str,
|
||||
sepfn: &fn(char) -> bool,
|
||||
it: &fn(&'a str) -> bool) {
|
||||
each_split_inner(s, sepfn, len(s), false, false, it);
|
||||
}
|
||||
/// Like `each_split`, but omits empty strings
|
||||
#[cfg(not(stage0))]
|
||||
pub fn each_split_nonempty<'a>(s: &'a str,
|
||||
sepfn: &fn(char) -> bool,
|
||||
it: &fn(&'a str) -> bool) -> bool {
|
||||
@ -754,36 +681,6 @@ fn each_split_inner<'a>(s: &'a str,
|
||||
}
|
||||
|
||||
// See Issue #1932 for why this is a naive search
|
||||
#[cfg(stage0)]
|
||||
fn iter_matches<'a,'b>(s: &'a str, sep: &'b str,
|
||||
f: &fn(uint, uint) -> bool) {
|
||||
let sep_len = len(sep), l = len(s);
|
||||
assert!(sep_len > 0u);
|
||||
let mut i = 0u, match_start = 0u, match_i = 0u;
|
||||
|
||||
while i < l {
|
||||
if s[i] == sep[match_i] {
|
||||
if match_i == 0u { match_start = i; }
|
||||
match_i += 1u;
|
||||
// Found a match
|
||||
if match_i == sep_len {
|
||||
if !f(match_start, i + 1u) { return; }
|
||||
match_i = 0u;
|
||||
}
|
||||
i += 1u;
|
||||
} else {
|
||||
// Failed match, backtrack
|
||||
if match_i > 0u {
|
||||
match_i = 0u;
|
||||
i = match_start + 1u;
|
||||
} else {
|
||||
i += 1u;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// See Issue #1932 for why this is a naive search
|
||||
#[cfg(not(stage0))]
|
||||
fn iter_matches<'a,'b>(s: &'a str, sep: &'b str,
|
||||
f: &fn(uint, uint) -> bool) -> bool {
|
||||
let sep_len = len(sep), l = len(s);
|
||||
@ -813,18 +710,6 @@ fn iter_matches<'a,'b>(s: &'a str, sep: &'b str,
|
||||
return true;
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
fn iter_between_matches<'a,'b>(s: &'a str,
|
||||
sep: &'b str,
|
||||
f: &fn(uint, uint) -> bool) {
|
||||
let mut last_end = 0u;
|
||||
for iter_matches(s, sep) |from, to| {
|
||||
if !f(last_end, from) { return; }
|
||||
last_end = to;
|
||||
}
|
||||
f(last_end, len(s));
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
fn iter_between_matches<'a,'b>(s: &'a str,
|
||||
sep: &'b str,
|
||||
f: &fn(uint, uint) -> bool) -> bool {
|
||||
@ -847,26 +732,6 @@ fn iter_between_matches<'a,'b>(s: &'a str,
|
||||
* assert!(v == ["", "XXX", "YYY", ""]);
|
||||
* ~~~
|
||||
*/
|
||||
#[cfg(stage0)]
|
||||
pub fn each_split_str<'a,'b>(s: &'a str,
|
||||
sep: &'b str,
|
||||
it: &fn(&'a str) -> bool) {
|
||||
for iter_between_matches(s, sep) |from, to| {
|
||||
if !it( unsafe { raw::slice_bytes(s, from, to) } ) { return; }
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Splits a string into a vector of the substrings separated by a given string
|
||||
*
|
||||
* # Example
|
||||
*
|
||||
* ~~~
|
||||
* let mut v = ~[];
|
||||
* for each_split_str(".XXX.YYY.", ".") |subs| { v.push(subs); }
|
||||
* assert!(v == ["", "XXX", "YYY", ""]);
|
||||
* ~~~
|
||||
*/
|
||||
#[cfg(not(stage0))]
|
||||
pub fn each_split_str<'a,'b>(s: &'a str,
|
||||
sep: &'b str,
|
||||
it: &fn(&'a str) -> bool) -> bool {
|
||||
@ -876,18 +741,6 @@ pub fn each_split_str<'a,'b>(s: &'a str,
|
||||
return true;
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub fn each_split_str_nonempty<'a,'b>(s: &'a str,
|
||||
sep: &'b str,
|
||||
it: &fn(&'a str) -> bool) {
|
||||
for iter_between_matches(s, sep) |from, to| {
|
||||
if to > from {
|
||||
if !it( unsafe { raw::slice_bytes(s, from, to) } ) { return; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
pub fn each_split_str_nonempty<'a,'b>(s: &'a str,
|
||||
sep: &'b str,
|
||||
it: &fn(&'a str) -> bool) -> bool {
|
||||
@ -936,14 +789,6 @@ pub fn levdistance(s: &str, t: &str) -> uint {
|
||||
/**
|
||||
* Splits a string into substrings separated by LF ('\n').
|
||||
*/
|
||||
#[cfg(stage0)]
|
||||
pub fn each_line<'a>(s: &'a str, it: &fn(&'a str) -> bool) {
|
||||
each_split_char_no_trailing(s, '\n', it);
|
||||
}
|
||||
/**
|
||||
* Splits a string into substrings separated by LF ('\n').
|
||||
*/
|
||||
#[cfg(not(stage0))]
|
||||
pub fn each_line<'a>(s: &'a str, it: &fn(&'a str) -> bool) -> bool {
|
||||
each_split_char_no_trailing(s, '\n', it)
|
||||
}
|
||||
@ -952,22 +797,6 @@ pub fn each_line<'a>(s: &'a str, it: &fn(&'a str) -> bool) -> bool {
|
||||
* Splits a string into substrings separated by LF ('\n')
|
||||
* and/or CR LF ("\r\n")
|
||||
*/
|
||||
#[cfg(stage0)]
|
||||
pub fn each_line_any<'a>(s: &'a str, it: &fn(&'a str) -> bool) {
|
||||
for each_line(s) |s| {
|
||||
let l = s.len();
|
||||
if l > 0u && s[l - 1u] == '\r' as u8 {
|
||||
if !it( unsafe { raw::slice_bytes(s, 0, l - 1) } ) { return; }
|
||||
} else {
|
||||
if !it( s ) { return; }
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Splits a string into substrings separated by LF ('\n')
|
||||
* and/or CR LF ("\r\n")
|
||||
*/
|
||||
#[cfg(not(stage0))]
|
||||
pub fn each_line_any<'a>(s: &'a str, it: &fn(&'a str) -> bool) -> bool {
|
||||
for each_line(s) |s| {
|
||||
let l = s.len();
|
||||
@ -981,12 +810,6 @@ pub fn each_line_any<'a>(s: &'a str, it: &fn(&'a str) -> bool) -> bool {
|
||||
}
|
||||
|
||||
/// Splits a string into substrings separated by whitespace
|
||||
#[cfg(stage0)]
|
||||
pub fn each_word<'a>(s: &'a str, it: &fn(&'a str) -> bool) {
|
||||
each_split_nonempty(s, char::is_whitespace, it);
|
||||
}
|
||||
/// Splits a string into substrings separated by whitespace
|
||||
#[cfg(not(stage0))]
|
||||
pub fn each_word<'a>(s: &'a str, it: &fn(&'a str) -> bool) -> bool {
|
||||
each_split_nonempty(s, char::is_whitespace, it)
|
||||
}
|
||||
@ -1063,13 +886,6 @@ pub fn _each_split_within<'a>(ss: &'a str,
|
||||
return cont;
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub fn each_split_within<'a>(ss: &'a str,
|
||||
lim: uint,
|
||||
it: &fn(&'a str) -> bool) {
|
||||
_each_split_within(ss, lim, it);
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
pub fn each_split_within<'a>(ss: &'a str,
|
||||
lim: uint,
|
||||
it: &fn(&'a str) -> bool) -> bool {
|
||||
@ -1352,33 +1168,12 @@ pub fn map(ss: &str, ff: &fn(char) -> char) -> ~str {
|
||||
|
||||
/// Iterate over the bytes in a string
|
||||
#[inline(always)]
|
||||
#[cfg(stage0)]
|
||||
pub fn each(s: &str, it: &fn(u8) -> bool) {
|
||||
eachi(s, |_i, b| it(b))
|
||||
}
|
||||
/// Iterate over the bytes in a string
|
||||
#[inline(always)]
|
||||
#[cfg(not(stage0))]
|
||||
pub fn each(s: &str, it: &fn(u8) -> bool) -> bool {
|
||||
eachi(s, |_i, b| it(b))
|
||||
}
|
||||
|
||||
/// Iterate over the bytes in a string, with indices
|
||||
#[inline(always)]
|
||||
#[cfg(stage0)]
|
||||
pub fn eachi(s: &str, it: &fn(uint, u8) -> bool) {
|
||||
let mut pos = 0;
|
||||
let len = s.len();
|
||||
|
||||
while pos < len {
|
||||
if !it(pos, s[pos]) { break; }
|
||||
pos += 1;
|
||||
}
|
||||
}
|
||||
|
||||
/// Iterate over the bytes in a string, with indices
|
||||
#[inline(always)]
|
||||
#[cfg(not(stage0))]
|
||||
pub fn eachi(s: &str, it: &fn(uint, u8) -> bool) -> bool {
|
||||
let mut pos = 0;
|
||||
let len = s.len();
|
||||
@ -1392,30 +1187,12 @@ pub fn eachi(s: &str, it: &fn(uint, u8) -> bool) -> bool {
|
||||
|
||||
/// Iterate over the bytes in a string in reverse
|
||||
#[inline(always)]
|
||||
#[cfg(stage0)]
|
||||
pub fn each_reverse(s: &str, it: &fn(u8) -> bool) {
|
||||
eachi_reverse(s, |_i, b| it(b) )
|
||||
}
|
||||
/// Iterate over the bytes in a string in reverse
|
||||
#[inline(always)]
|
||||
#[cfg(not(stage0))]
|
||||
pub fn each_reverse(s: &str, it: &fn(u8) -> bool) -> bool {
|
||||
eachi_reverse(s, |_i, b| it(b) )
|
||||
}
|
||||
|
||||
/// Iterate over the bytes in a string in reverse, with indices
|
||||
#[inline(always)]
|
||||
#[cfg(stage0)]
|
||||
pub fn eachi_reverse(s: &str, it: &fn(uint, u8) -> bool) {
|
||||
let mut pos = s.len();
|
||||
while pos > 0 {
|
||||
pos -= 1;
|
||||
if !it(pos, s[pos]) { break; }
|
||||
}
|
||||
}
|
||||
/// Iterate over the bytes in a string in reverse, with indices
|
||||
#[inline(always)]
|
||||
#[cfg(not(stage0))]
|
||||
pub fn eachi_reverse(s: &str, it: &fn(uint, u8) -> bool) -> bool {
|
||||
let mut pos = s.len();
|
||||
while pos > 0 {
|
||||
@ -1427,19 +1204,6 @@ pub fn eachi_reverse(s: &str, it: &fn(uint, u8) -> bool) -> bool {
|
||||
|
||||
/// Iterate over each char of a string, without allocating
|
||||
#[inline(always)]
|
||||
#[cfg(stage0)]
|
||||
pub fn each_char(s: &str, it: &fn(char) -> bool) {
|
||||
let mut i = 0;
|
||||
let len = len(s);
|
||||
while i < len {
|
||||
let CharRange {ch, next} = char_range_at(s, i);
|
||||
if !it(ch) { return; }
|
||||
i = next;
|
||||
}
|
||||
}
|
||||
/// Iterate over each char of a string, without allocating
|
||||
#[inline(always)]
|
||||
#[cfg(not(stage0))]
|
||||
pub fn each_char(s: &str, it: &fn(char) -> bool) -> bool {
|
||||
let mut i = 0;
|
||||
let len = len(s);
|
||||
@ -1453,21 +1217,6 @@ pub fn each_char(s: &str, it: &fn(char) -> bool) -> bool {
|
||||
|
||||
/// Iterates over the chars in a string, with indices
|
||||
#[inline(always)]
|
||||
#[cfg(stage0)]
|
||||
pub fn each_chari(s: &str, it: &fn(uint, char) -> bool) {
|
||||
let mut pos = 0;
|
||||
let mut ch_pos = 0u;
|
||||
let len = s.len();
|
||||
while pos < len {
|
||||
let CharRange {ch, next} = char_range_at(s, pos);
|
||||
pos = next;
|
||||
if !it(ch_pos, ch) { break; }
|
||||
ch_pos += 1u;
|
||||
}
|
||||
}
|
||||
/// Iterates over the chars in a string, with indices
|
||||
#[inline(always)]
|
||||
#[cfg(not(stage0))]
|
||||
pub fn each_chari(s: &str, it: &fn(uint, char) -> bool) -> bool {
|
||||
let mut pos = 0;
|
||||
let mut ch_pos = 0u;
|
||||
@ -1483,35 +1232,12 @@ pub fn each_chari(s: &str, it: &fn(uint, char) -> bool) -> bool {
|
||||
|
||||
/// Iterates over the chars in a string in reverse
|
||||
#[inline(always)]
|
||||
#[cfg(stage0)]
|
||||
pub fn each_char_reverse(s: &str, it: &fn(char) -> bool) {
|
||||
each_chari_reverse(s, |_, c| it(c))
|
||||
}
|
||||
/// Iterates over the chars in a string in reverse
|
||||
#[inline(always)]
|
||||
#[cfg(not(stage0))]
|
||||
pub fn each_char_reverse(s: &str, it: &fn(char) -> bool) -> bool {
|
||||
each_chari_reverse(s, |_, c| it(c))
|
||||
}
|
||||
|
||||
// Iterates over the chars in a string in reverse, with indices
|
||||
#[inline(always)]
|
||||
#[cfg(stage0)]
|
||||
pub fn each_chari_reverse(s: &str, it: &fn(uint, char) -> bool) {
|
||||
let mut pos = s.len();
|
||||
let mut ch_pos = s.char_len();
|
||||
while pos > 0 {
|
||||
let CharRange {ch, next} = char_range_at_reverse(s, pos);
|
||||
pos = next;
|
||||
ch_pos -= 1;
|
||||
|
||||
if !it(ch_pos, ch) { break; }
|
||||
|
||||
}
|
||||
}
|
||||
// Iterates over the chars in a string in reverse, with indices
|
||||
#[inline(always)]
|
||||
#[cfg(not(stage0))]
|
||||
pub fn each_chari_reverse(s: &str, it: &fn(uint, char) -> bool) -> bool {
|
||||
let mut pos = s.len();
|
||||
let mut ch_pos = s.char_len();
|
||||
@ -2761,22 +2487,14 @@ pub trait StrSlice<'self> {
|
||||
fn contains<'a>(&self, needle: &'a str) -> bool;
|
||||
fn contains_char(&self, needle: char) -> bool;
|
||||
fn char_iter(&self) -> StrCharIterator<'self>;
|
||||
#[cfg(stage0)] fn each(&self, it: &fn(u8) -> bool);
|
||||
#[cfg(not(stage0))] fn each(&self, it: &fn(u8) -> bool) -> bool;
|
||||
#[cfg(stage0)] fn eachi(&self, it: &fn(uint, u8) -> bool);
|
||||
#[cfg(not(stage0))] fn eachi(&self, it: &fn(uint, u8) -> bool) -> bool;
|
||||
#[cfg(stage0)] fn each_reverse(&self, it: &fn(u8) -> bool);
|
||||
#[cfg(not(stage0))] fn each_reverse(&self, it: &fn(u8) -> bool) -> bool;
|
||||
#[cfg(stage0)] fn eachi_reverse(&self, it: &fn(uint, u8) -> bool);
|
||||
#[cfg(not(stage0))] fn eachi_reverse(&self, it: &fn(uint, u8) -> bool) -> bool;
|
||||
#[cfg(stage0)] fn each_char(&self, it: &fn(char) -> bool);
|
||||
#[cfg(not(stage0))] fn each_char(&self, it: &fn(char) -> bool) -> bool;
|
||||
#[cfg(stage0)] fn each_chari(&self, it: &fn(uint, char) -> bool);
|
||||
#[cfg(not(stage0))] fn each_chari(&self, it: &fn(uint, char) -> bool) -> bool;
|
||||
#[cfg(stage0)] fn each_char_reverse(&self, it: &fn(char) -> bool);
|
||||
#[cfg(not(stage0))] fn each_char_reverse(&self, it: &fn(char) -> bool) -> bool;
|
||||
#[cfg(stage0)] fn each_chari_reverse(&self, it: &fn(uint, char) -> bool);
|
||||
#[cfg(not(stage0))] fn each_chari_reverse(&self, it: &fn(uint, char) -> bool) -> bool;
|
||||
fn each(&self, it: &fn(u8) -> bool) -> bool;
|
||||
fn eachi(&self, it: &fn(uint, u8) -> bool) -> bool;
|
||||
fn each_reverse(&self, it: &fn(u8) -> bool) -> bool;
|
||||
fn eachi_reverse(&self, it: &fn(uint, u8) -> bool) -> bool;
|
||||
fn each_char(&self, it: &fn(char) -> bool) -> bool;
|
||||
fn each_chari(&self, it: &fn(uint, char) -> bool) -> bool;
|
||||
fn each_char_reverse(&self, it: &fn(char) -> bool) -> bool;
|
||||
fn each_chari_reverse(&self, it: &fn(uint, char) -> bool) -> bool;
|
||||
fn ends_with(&self, needle: &str) -> bool;
|
||||
fn is_empty(&self) -> bool;
|
||||
fn is_whitespace(&self) -> bool;
|
||||
@ -2784,17 +2502,8 @@ pub trait StrSlice<'self> {
|
||||
fn len(&self) -> uint;
|
||||
fn char_len(&self) -> uint;
|
||||
fn slice(&self, begin: uint, end: uint) -> &'self str;
|
||||
#[cfg(stage0)]
|
||||
fn each_split(&self, sepfn: &fn(char) -> bool, it: &fn(&'self str) -> bool);
|
||||
#[cfg(not(stage0))]
|
||||
fn each_split(&self, sepfn: &fn(char) -> bool, it: &fn(&'self str) -> bool) -> bool;
|
||||
#[cfg(stage0)]
|
||||
fn each_split_char(&self, sep: char, it: &fn(&'self str) -> bool);
|
||||
#[cfg(not(stage0))]
|
||||
fn each_split_char(&self, sep: char, it: &fn(&'self str) -> bool) -> bool;
|
||||
#[cfg(stage0)]
|
||||
fn each_split_str<'a>(&self, sep: &'a str, it: &fn(&'self str) -> bool);
|
||||
#[cfg(not(stage0))]
|
||||
fn each_split_str<'a>(&self, sep: &'a str, it: &fn(&'self str) -> bool) -> bool;
|
||||
fn starts_with<'a>(&self, needle: &'a str) -> bool;
|
||||
fn substr(&self, begin: uint, n: uint) -> &'self str;
|
||||
@ -2848,83 +2557,34 @@ impl<'self> StrSlice<'self> for &'self str {
|
||||
|
||||
/// Iterate over the bytes in a string
|
||||
#[inline]
|
||||
#[cfg(stage0)]
|
||||
fn each(&self, it: &fn(u8) -> bool) { each(*self, it) }
|
||||
/// Iterate over the bytes in a string
|
||||
#[inline]
|
||||
#[cfg(not(stage0))]
|
||||
fn each(&self, it: &fn(u8) -> bool) -> bool { each(*self, it) }
|
||||
/// Iterate over the bytes in a string, with indices
|
||||
#[inline]
|
||||
#[cfg(stage0)]
|
||||
fn eachi(&self, it: &fn(uint, u8) -> bool) { eachi(*self, it) }
|
||||
/// Iterate over the bytes in a string, with indices
|
||||
#[inline]
|
||||
#[cfg(not(stage0))]
|
||||
fn eachi(&self, it: &fn(uint, u8) -> bool) -> bool { eachi(*self, it) }
|
||||
/// Iterate over the bytes in a string
|
||||
#[inline]
|
||||
#[cfg(stage0)]
|
||||
fn each_reverse(&self, it: &fn(u8) -> bool) { each_reverse(*self, it) }
|
||||
/// Iterate over the bytes in a string
|
||||
#[inline]
|
||||
#[cfg(not(stage0))]
|
||||
fn each_reverse(&self, it: &fn(u8) -> bool) -> bool { each_reverse(*self, it) }
|
||||
/// Iterate over the bytes in a string, with indices
|
||||
#[inline]
|
||||
#[cfg(stage0)]
|
||||
fn eachi_reverse(&self, it: &fn(uint, u8) -> bool) {
|
||||
eachi_reverse(*self, it)
|
||||
}
|
||||
/// Iterate over the bytes in a string, with indices
|
||||
#[inline]
|
||||
#[cfg(not(stage0))]
|
||||
fn eachi_reverse(&self, it: &fn(uint, u8) -> bool) -> bool {
|
||||
eachi_reverse(*self, it)
|
||||
}
|
||||
/// Iterate over the chars in a string
|
||||
#[inline]
|
||||
#[cfg(stage0)]
|
||||
fn each_char(&self, it: &fn(char) -> bool) { each_char(*self, it) }
|
||||
/// Iterate over the chars in a string
|
||||
#[inline]
|
||||
#[cfg(not(stage0))]
|
||||
fn each_char(&self, it: &fn(char) -> bool) -> bool { each_char(*self, it) }
|
||||
/// Iterate over the chars in a string, with indices
|
||||
#[inline]
|
||||
#[cfg(stage0)]
|
||||
fn each_chari(&self, it: &fn(uint, char) -> bool) {
|
||||
each_chari(*self, it)
|
||||
}
|
||||
/// Iterate over the chars in a string, with indices
|
||||
#[inline]
|
||||
#[cfg(not(stage0))]
|
||||
fn each_chari(&self, it: &fn(uint, char) -> bool) -> bool {
|
||||
each_chari(*self, it)
|
||||
}
|
||||
/// Iterate over the chars in a string in reverse
|
||||
#[inline]
|
||||
#[cfg(stage0)]
|
||||
fn each_char_reverse(&self, it: &fn(char) -> bool) {
|
||||
each_char_reverse(*self, it)
|
||||
}
|
||||
/// Iterate over the chars in a string in reverse
|
||||
#[inline]
|
||||
#[cfg(not(stage0))]
|
||||
fn each_char_reverse(&self, it: &fn(char) -> bool) -> bool {
|
||||
each_char_reverse(*self, it)
|
||||
}
|
||||
/// Iterate over the chars in a string in reverse, with indices from the
|
||||
/// end
|
||||
#[inline]
|
||||
#[cfg(stage0)]
|
||||
fn each_chari_reverse(&self, it: &fn(uint, char) -> bool) {
|
||||
each_chari_reverse(*self, it)
|
||||
}
|
||||
/// Iterate over the chars in a string in reverse, with indices from the
|
||||
/// end
|
||||
#[inline]
|
||||
#[cfg(not(stage0))]
|
||||
fn each_chari_reverse(&self, it: &fn(uint, char) -> bool) -> bool {
|
||||
each_chari_reverse(*self, it)
|
||||
}
|
||||
@ -2969,13 +2629,6 @@ impl<'self> StrSlice<'self> for &'self str {
|
||||
}
|
||||
/// Splits a string into substrings using a character function
|
||||
#[inline]
|
||||
#[cfg(stage0)]
|
||||
fn each_split(&self, sepfn: &fn(char) -> bool, it: &fn(&'self str) -> bool) {
|
||||
each_split(*self, sepfn, it)
|
||||
}
|
||||
/// Splits a string into substrings using a character function
|
||||
#[inline]
|
||||
#[cfg(not(stage0))]
|
||||
fn each_split(&self, sepfn: &fn(char) -> bool, it: &fn(&'self str) -> bool) -> bool {
|
||||
each_split(*self, sepfn, it)
|
||||
}
|
||||
@ -2983,15 +2636,6 @@ impl<'self> StrSlice<'self> for &'self str {
|
||||
* Splits a string into substrings at each occurrence of a given character
|
||||
*/
|
||||
#[inline]
|
||||
#[cfg(stage0)]
|
||||
fn each_split_char(&self, sep: char, it: &fn(&'self str) -> bool) {
|
||||
each_split_char(*self, sep, it)
|
||||
}
|
||||
/**
|
||||
* Splits a string into substrings at each occurrence of a given character
|
||||
*/
|
||||
#[inline]
|
||||
#[cfg(not(stage0))]
|
||||
fn each_split_char(&self, sep: char, it: &fn(&'self str) -> bool) -> bool {
|
||||
each_split_char(*self, sep, it)
|
||||
}
|
||||
@ -3000,16 +2644,6 @@ impl<'self> StrSlice<'self> for &'self str {
|
||||
* string
|
||||
*/
|
||||
#[inline]
|
||||
#[cfg(stage0)]
|
||||
fn each_split_str<'a>(&self, sep: &'a str, it: &fn(&'self str) -> bool) {
|
||||
each_split_str(*self, sep, it)
|
||||
}
|
||||
/**
|
||||
* Splits a string into a vector of the substrings separated by a given
|
||||
* string
|
||||
*/
|
||||
#[inline]
|
||||
#[cfg(not(stage0))]
|
||||
fn each_split_str<'a>(&self, sep: &'a str, it: &fn(&'self str) -> bool) -> bool {
|
||||
each_split_str(*self, sep, it)
|
||||
}
|
||||
|
@ -110,11 +110,6 @@ fn taskset_remove(tasks: &mut TaskSet, task: *rust_task) {
|
||||
let was_present = tasks.remove(&task);
|
||||
assert!(was_present);
|
||||
}
|
||||
#[cfg(stage0)]
|
||||
pub fn taskset_each(tasks: &TaskSet, blk: &fn(v: *rust_task) -> bool) {
|
||||
tasks.each(|k| blk(*k))
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
pub fn taskset_each(tasks: &TaskSet, blk: &fn(v: *rust_task) -> bool) -> bool {
|
||||
tasks.each(|k| blk(*k))
|
||||
}
|
||||
|
@ -22,11 +22,6 @@ use str;
|
||||
|
||||
pub type Cb<'self> = &'self fn(buf: &[u8]) -> bool;
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub trait IterBytes {
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb);
|
||||
}
|
||||
|
||||
/**
|
||||
* A trait to implement in order to make a type hashable;
|
||||
* This works in combination with the trait `Hash::Hash`, and
|
||||
@ -34,7 +29,6 @@ pub trait IterBytes {
|
||||
* modified when default methods and trait inheritence are
|
||||
* completed.
|
||||
*/
|
||||
#[cfg(not(stage0))]
|
||||
pub trait IterBytes {
|
||||
/**
|
||||
* Call the provided callback `f` one or more times with
|
||||
@ -53,16 +47,6 @@ pub trait IterBytes {
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool;
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl IterBytes for bool {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, _lsb0: bool, f: Cb) {
|
||||
f([
|
||||
*self as u8
|
||||
]);
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl IterBytes for bool {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, _lsb0: bool, f: Cb) -> bool {
|
||||
@ -72,16 +56,6 @@ impl IterBytes for bool {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl IterBytes for u8 {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, _lsb0: bool, f: Cb) {
|
||||
f([
|
||||
*self
|
||||
]);
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl IterBytes for u8 {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, _lsb0: bool, f: Cb) -> bool {
|
||||
@ -91,24 +65,6 @@ impl IterBytes for u8 {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl IterBytes for u16 {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
if lsb0 {
|
||||
f([
|
||||
*self as u8,
|
||||
(*self >> 8) as u8
|
||||
]);
|
||||
} else {
|
||||
f([
|
||||
(*self >> 8) as u8,
|
||||
*self as u8
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl IterBytes for u16 {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
|
||||
@ -126,28 +82,6 @@ impl IterBytes for u16 {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl IterBytes for u32 {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
if lsb0 {
|
||||
f([
|
||||
*self as u8,
|
||||
(*self >> 8) as u8,
|
||||
(*self >> 16) as u8,
|
||||
(*self >> 24) as u8,
|
||||
]);
|
||||
} else {
|
||||
f([
|
||||
(*self >> 24) as u8,
|
||||
(*self >> 16) as u8,
|
||||
(*self >> 8) as u8,
|
||||
*self as u8
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl IterBytes for u32 {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
|
||||
@ -169,36 +103,6 @@ impl IterBytes for u32 {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl IterBytes for u64 {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
if lsb0 {
|
||||
f([
|
||||
*self as u8,
|
||||
(*self >> 8) as u8,
|
||||
(*self >> 16) as u8,
|
||||
(*self >> 24) as u8,
|
||||
(*self >> 32) as u8,
|
||||
(*self >> 40) as u8,
|
||||
(*self >> 48) as u8,
|
||||
(*self >> 56) as u8
|
||||
]);
|
||||
} else {
|
||||
f([
|
||||
(*self >> 56) as u8,
|
||||
(*self >> 48) as u8,
|
||||
(*self >> 40) as u8,
|
||||
(*self >> 32) as u8,
|
||||
(*self >> 24) as u8,
|
||||
(*self >> 16) as u8,
|
||||
(*self >> 8) as u8,
|
||||
*self as u8
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl IterBytes for u64 {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
|
||||
@ -228,14 +132,6 @@ impl IterBytes for u64 {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl IterBytes for i8 {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
(*self as u8).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl IterBytes for i8 {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
|
||||
@ -243,14 +139,6 @@ impl IterBytes for i8 {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl IterBytes for i16 {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
(*self as u16).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl IterBytes for i16 {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
|
||||
@ -258,14 +146,6 @@ impl IterBytes for i16 {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl IterBytes for i32 {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
(*self as u32).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl IterBytes for i32 {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
|
||||
@ -273,14 +153,6 @@ impl IterBytes for i32 {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl IterBytes for i64 {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
(*self as u64).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl IterBytes for i64 {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
|
||||
@ -288,14 +160,6 @@ impl IterBytes for i64 {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl IterBytes for char {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
(*self as u32).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl IterBytes for char {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
|
||||
@ -303,14 +167,7 @@ impl IterBytes for char {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_word_size = "32", stage0)]
|
||||
impl IterBytes for uint {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
(*self as u32).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
#[cfg(target_word_size = "32", not(stage0))]
|
||||
#[cfg(target_word_size = "32")]
|
||||
impl IterBytes for uint {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
|
||||
@ -318,14 +175,7 @@ impl IterBytes for uint {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_word_size = "64", stage0)]
|
||||
impl IterBytes for uint {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
(*self as u64).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
#[cfg(target_word_size = "64", not(stage0))]
|
||||
#[cfg(target_word_size = "64")]
|
||||
impl IterBytes for uint {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
|
||||
@ -333,14 +183,6 @@ impl IterBytes for uint {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl IterBytes for int {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
(*self as uint).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl IterBytes for int {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
|
||||
@ -348,18 +190,6 @@ impl IterBytes for int {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl<'self,A:IterBytes> IterBytes for &'self [A] {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
for (*self).each |elt| {
|
||||
do elt.iter_bytes(lsb0) |bytes| {
|
||||
f(bytes)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl<'self,A:IterBytes> IterBytes for &'self [A] {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
|
||||
@ -367,18 +197,6 @@ impl<'self,A:IterBytes> IterBytes for &'self [A] {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl<A:IterBytes,B:IterBytes> IterBytes for (A,B) {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
match *self {
|
||||
(ref a, ref b) => {
|
||||
iter_bytes_2(a, b, lsb0, f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl<A:IterBytes,B:IterBytes> IterBytes for (A,B) {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
|
||||
@ -388,18 +206,6 @@ impl<A:IterBytes,B:IterBytes> IterBytes for (A,B) {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl<A:IterBytes,B:IterBytes,C:IterBytes> IterBytes for (A,B,C) {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
match *self {
|
||||
(ref a, ref b, ref c) => {
|
||||
iter_bytes_3(a, b, c, lsb0, f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl<A:IterBytes,B:IterBytes,C:IterBytes> IterBytes for (A,B,C) {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
|
||||
@ -416,14 +222,6 @@ fn borrow<'x,A>(a: &'x [A]) -> &'x [A] {
|
||||
a
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl<A:IterBytes> IterBytes for ~[A] {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
borrow(*self).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl<A:IterBytes> IterBytes for ~[A] {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
|
||||
@ -431,14 +229,6 @@ impl<A:IterBytes> IterBytes for ~[A] {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl<A:IterBytes> IterBytes for @[A] {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
borrow(*self).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl<A:IterBytes> IterBytes for @[A] {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
|
||||
@ -449,57 +239,18 @@ impl<A:IterBytes> IterBytes for @[A] {
|
||||
// NOTE: remove all of these after a snapshot, the new for-loop iteration
|
||||
// protocol makes these unnecessary.
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub fn iter_bytes_2<A:IterBytes,B:IterBytes>(a: &A, b: &B,
|
||||
lsb0: bool, z: Cb) {
|
||||
let mut flag = true;
|
||||
a.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag});
|
||||
if !flag { return; }
|
||||
b.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag});
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
#[inline(always)]
|
||||
pub fn iter_bytes_2<A:IterBytes,B:IterBytes>(a: &A, b: &B,
|
||||
lsb0: bool, z: Cb) -> bool {
|
||||
a.iter_bytes(lsb0, z) && b.iter_bytes(lsb0, z)
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub fn iter_bytes_3<A: IterBytes,
|
||||
B: IterBytes,
|
||||
C: IterBytes>(a: &A, b: &B, c: &C,
|
||||
lsb0: bool, z: Cb) {
|
||||
let mut flag = true;
|
||||
a.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag});
|
||||
if !flag { return; }
|
||||
b.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag});
|
||||
if !flag { return; }
|
||||
c.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag});
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
pub fn iter_bytes_3<A: IterBytes,
|
||||
B: IterBytes,
|
||||
C: IterBytes>(a: &A, b: &B, c: &C, lsb0: bool, z: Cb) -> bool {
|
||||
a.iter_bytes(lsb0, z) && b.iter_bytes(lsb0, z) && c.iter_bytes(lsb0, z)
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub fn iter_bytes_4<A: IterBytes,
|
||||
B: IterBytes,
|
||||
C: IterBytes,
|
||||
D: IterBytes>(a: &A, b: &B, c: &C,
|
||||
d: &D,
|
||||
lsb0: bool, z: Cb) {
|
||||
let mut flag = true;
|
||||
a.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag});
|
||||
if !flag { return; }
|
||||
b.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag});
|
||||
if !flag { return; }
|
||||
c.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag});
|
||||
if !flag { return; }
|
||||
d.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag});
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
pub fn iter_bytes_4<A: IterBytes,
|
||||
B: IterBytes,
|
||||
C: IterBytes,
|
||||
@ -510,26 +261,6 @@ pub fn iter_bytes_4<A: IterBytes,
|
||||
d.iter_bytes(lsb0, z)
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub fn iter_bytes_5<A: IterBytes,
|
||||
B: IterBytes,
|
||||
C: IterBytes,
|
||||
D: IterBytes,
|
||||
E: IterBytes>(a: &A, b: &B, c: &C,
|
||||
d: &D, e: &E,
|
||||
lsb0: bool, z: Cb) {
|
||||
let mut flag = true;
|
||||
a.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag});
|
||||
if !flag { return; }
|
||||
b.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag});
|
||||
if !flag { return; }
|
||||
c.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag});
|
||||
if !flag { return; }
|
||||
d.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag});
|
||||
if !flag { return; }
|
||||
e.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag});
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
pub fn iter_bytes_5<A: IterBytes,
|
||||
B: IterBytes,
|
||||
C: IterBytes,
|
||||
@ -541,16 +272,6 @@ pub fn iter_bytes_5<A: IterBytes,
|
||||
d.iter_bytes(lsb0, z) && e.iter_bytes(lsb0, z)
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl<'self> IterBytes for &'self str {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, _lsb0: bool, f: Cb) {
|
||||
do str::byte_slice(*self) |bytes| {
|
||||
f(bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl<'self> IterBytes for &'self str {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, _lsb0: bool, f: Cb) -> bool {
|
||||
@ -560,16 +281,6 @@ impl<'self> IterBytes for &'self str {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl IterBytes for ~str {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, _lsb0: bool, f: Cb) {
|
||||
do str::byte_slice(*self) |bytes| {
|
||||
f(bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl IterBytes for ~str {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, _lsb0: bool, f: Cb) -> bool {
|
||||
@ -579,16 +290,6 @@ impl IterBytes for ~str {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl IterBytes for @str {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, _lsb0: bool, f: Cb) {
|
||||
do str::byte_slice(*self) |bytes| {
|
||||
f(bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl IterBytes for @str {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, _lsb0: bool, f: Cb) -> bool {
|
||||
@ -598,17 +299,6 @@ impl IterBytes for @str {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl<A:IterBytes> IterBytes for Option<A> {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
match *self {
|
||||
Some(ref a) => iter_bytes_2(&0u8, a, lsb0, f),
|
||||
None => 1u8.iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl<A:IterBytes> IterBytes for Option<A> {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
|
||||
@ -619,14 +309,6 @@ impl<A:IterBytes> IterBytes for Option<A> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl<'self,A:IterBytes> IterBytes for &'self A {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
(**self).iter_bytes(lsb0, f);
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl<'self,A:IterBytes> IterBytes for &'self A {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
|
||||
@ -634,14 +316,6 @@ impl<'self,A:IterBytes> IterBytes for &'self A {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl<A:IterBytes> IterBytes for @A {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
(**self).iter_bytes(lsb0, f);
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl<A:IterBytes> IterBytes for @A {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
|
||||
@ -649,14 +323,6 @@ impl<A:IterBytes> IterBytes for @A {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl<A:IterBytes> IterBytes for ~A {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
(**self).iter_bytes(lsb0, f);
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl<A:IterBytes> IterBytes for ~A {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
|
||||
@ -666,16 +332,6 @@ impl<A:IterBytes> IterBytes for ~A {
|
||||
|
||||
// NB: raw-pointer IterBytes does _not_ dereference
|
||||
// to the target; it just gives you the pointer-bytes.
|
||||
#[cfg(stage0)]
|
||||
impl<A> IterBytes for *const A {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
(*self as uint).iter_bytes(lsb0, f);
|
||||
}
|
||||
}
|
||||
// NB: raw-pointer IterBytes does _not_ dereference
|
||||
// to the target; it just gives you the pointer-bytes.
|
||||
#[cfg(not(stage0))]
|
||||
impl<A> IterBytes for *const A {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
|
||||
|
@ -57,56 +57,24 @@ impl<T> Map<uint, T> for TrieMap<T> {
|
||||
|
||||
/// Visit all key-value pairs in order
|
||||
#[inline(always)]
|
||||
#[cfg(stage0)]
|
||||
fn each<'a>(&'a self, f: &fn(&uint, &'a T) -> bool) {
|
||||
self.root.each(f);
|
||||
}
|
||||
|
||||
/// Visit all key-value pairs in order
|
||||
#[inline(always)]
|
||||
#[cfg(not(stage0))]
|
||||
fn each<'a>(&'a self, f: &fn(&uint, &'a T) -> bool) -> bool {
|
||||
self.root.each(f)
|
||||
}
|
||||
|
||||
/// Visit all keys in order
|
||||
#[inline(always)]
|
||||
#[cfg(stage0)]
|
||||
fn each_key(&self, f: &fn(&uint) -> bool) {
|
||||
self.each(|k, _| f(k))
|
||||
}
|
||||
|
||||
/// Visit all keys in order
|
||||
#[inline(always)]
|
||||
#[cfg(not(stage0))]
|
||||
fn each_key(&self, f: &fn(&uint) -> bool) -> bool {
|
||||
self.each(|k, _| f(k))
|
||||
}
|
||||
|
||||
/// Visit all values in order
|
||||
#[inline(always)]
|
||||
#[cfg(stage0)]
|
||||
fn each_value<'a>(&'a self, f: &fn(&'a T) -> bool) {
|
||||
self.each(|_, v| f(v))
|
||||
}
|
||||
|
||||
/// Visit all values in order
|
||||
#[inline(always)]
|
||||
#[cfg(not(stage0))]
|
||||
fn each_value<'a>(&'a self, f: &fn(&'a T) -> bool) -> bool {
|
||||
self.each(|_, v| f(v))
|
||||
}
|
||||
|
||||
/// Iterate over the map and mutate the contained values
|
||||
#[inline(always)]
|
||||
#[cfg(stage0)]
|
||||
fn mutate_values(&mut self, f: &fn(&uint, &mut T) -> bool) {
|
||||
self.root.mutate_values(f);
|
||||
}
|
||||
|
||||
/// Iterate over the map and mutate the contained values
|
||||
#[inline(always)]
|
||||
#[cfg(not(stage0))]
|
||||
fn mutate_values(&mut self, f: &fn(&uint, &mut T) -> bool) -> bool {
|
||||
self.root.mutate_values(f)
|
||||
}
|
||||
@ -183,40 +151,18 @@ pub impl<T> TrieMap<T> {
|
||||
|
||||
/// Visit all key-value pairs in reverse order
|
||||
#[inline(always)]
|
||||
#[cfg(stage0)]
|
||||
fn each_reverse<'a>(&'a self, f: &fn(&uint, &'a T) -> bool) {
|
||||
self.root.each_reverse(f);
|
||||
}
|
||||
|
||||
/// Visit all key-value pairs in reverse order
|
||||
#[inline(always)]
|
||||
#[cfg(not(stage0))]
|
||||
fn each_reverse<'a>(&'a self, f: &fn(&uint, &'a T) -> bool) -> bool {
|
||||
self.root.each_reverse(f)
|
||||
}
|
||||
|
||||
/// Visit all keys in reverse order
|
||||
#[inline(always)]
|
||||
#[cfg(stage0)]
|
||||
fn each_key_reverse(&self, f: &fn(&uint) -> bool) {
|
||||
self.each_reverse(|k, _| f(k))
|
||||
}
|
||||
/// Visit all keys in reverse order
|
||||
#[inline(always)]
|
||||
#[cfg(not(stage0))]
|
||||
fn each_key_reverse(&self, f: &fn(&uint) -> bool) -> bool {
|
||||
self.each_reverse(|k, _| f(k))
|
||||
}
|
||||
|
||||
/// Visit all values in reverse order
|
||||
#[inline(always)]
|
||||
#[cfg(stage0)]
|
||||
fn each_value_reverse(&self, f: &fn(&T) -> bool) {
|
||||
self.each_reverse(|_, v| f(v))
|
||||
}
|
||||
/// Visit all values in reverse order
|
||||
#[inline(always)]
|
||||
#[cfg(not(stage0))]
|
||||
fn each_value_reverse(&self, f: &fn(&T) -> bool) -> bool {
|
||||
self.each_reverse(|_, v| f(v))
|
||||
}
|
||||
@ -229,9 +175,6 @@ pub struct TrieSet {
|
||||
impl BaseIter<uint> for TrieSet {
|
||||
/// Visit all values in order
|
||||
#[inline(always)]
|
||||
#[cfg(stage0)]
|
||||
fn each(&self, f: &fn(&uint) -> bool) { self.map.each_key(f) }
|
||||
#[cfg(not(stage0))]
|
||||
fn each(&self, f: &fn(&uint) -> bool) -> bool { self.map.each_key(f) }
|
||||
#[inline(always)]
|
||||
fn size_hint(&self) -> Option<uint> { Some(self.len()) }
|
||||
@ -240,11 +183,6 @@ impl BaseIter<uint> for TrieSet {
|
||||
impl ReverseIter<uint> for TrieSet {
|
||||
/// Visit all values in reverse order
|
||||
#[inline(always)]
|
||||
#[cfg(stage0)]
|
||||
fn each_reverse(&self, f: &fn(&uint) -> bool) {
|
||||
self.map.each_key_reverse(f)
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
fn each_reverse(&self, f: &fn(&uint) -> bool) -> bool {
|
||||
self.map.each_key_reverse(f)
|
||||
}
|
||||
@ -351,19 +289,6 @@ fn chunk(n: uint, idx: uint) -> uint {
|
||||
(n >> sh) & MASK
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
fn find_mut<'r, T>(child: &'r mut Child<T>, key: uint, idx: uint) -> Option<&'r mut T> {
|
||||
unsafe {
|
||||
(match *child {
|
||||
External(_, ref value) => Some(cast::transmute_mut(value)),
|
||||
Internal(ref x) => find_mut(cast::transmute_mut(&x.children[chunk(key, idx)]),
|
||||
key, idx + 1),
|
||||
Nothing => None
|
||||
}).map_consume(|x| cast::transmute_mut_region(x))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
fn find_mut<'r, T>(child: &'r mut Child<T>, key: uint, idx: uint) -> Option<&'r mut T> {
|
||||
match *child {
|
||||
External(_, ref mut value) => Some(value),
|
||||
|
@ -14,19 +14,6 @@
|
||||
|
||||
pub mod general_category {
|
||||
|
||||
#[cfg(stage0)]
|
||||
fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool {
|
||||
use cmp::{Equal, Less, Greater};
|
||||
use vec::bsearch;
|
||||
use option::None;
|
||||
(do bsearch(r) |&(lo,hi)| {
|
||||
if lo <= c && c <= hi { Equal }
|
||||
else if hi < c { Less }
|
||||
else { Greater }
|
||||
}) != None
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool {
|
||||
use cmp::{Equal, Less, Greater};
|
||||
use vec::bsearch;
|
||||
@ -1462,19 +1449,6 @@ pub mod general_category {
|
||||
}
|
||||
|
||||
pub mod derived_property {
|
||||
#[cfg(stage0)]
|
||||
fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool {
|
||||
use cmp::{Equal, Less, Greater};
|
||||
use vec::bsearch;
|
||||
use option::None;
|
||||
(do bsearch(r) |&(lo,hi)| {
|
||||
if lo <= c && c <= hi { Equal }
|
||||
else if hi < c { Less }
|
||||
else { Greater }
|
||||
}) != None
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool {
|
||||
use cmp::{Equal, Less, Greater};
|
||||
use vec::bsearch;
|
||||
|
@ -43,17 +43,13 @@ pub extern "rust-intrinsic" {
|
||||
pub fn atomic_cxchg_rel(dst: &mut int, old: int, src: int) -> int;
|
||||
|
||||
/// Atomic load, sequentially consistent.
|
||||
#[cfg(not(stage0))]
|
||||
pub fn atomic_load(src: &int) -> int;
|
||||
/// Atomic load, acquire ordering.
|
||||
#[cfg(not(stage0))]
|
||||
pub fn atomic_load_acq(src: &int) -> int;
|
||||
|
||||
/// Atomic store, sequentially consistent.
|
||||
#[cfg(not(stage0))]
|
||||
pub fn atomic_store(dst: &mut int, val: int);
|
||||
/// Atomic store, release ordering.
|
||||
#[cfg(not(stage0))]
|
||||
pub fn atomic_store_rel(dst: &mut int, val: int);
|
||||
|
||||
/// Atomic exchange, sequentially consistent.
|
||||
@ -111,7 +107,6 @@ pub extern "rust-intrinsic" {
|
||||
pub unsafe fn init<T>() -> T;
|
||||
|
||||
/// Create an uninitialized value.
|
||||
#[cfg(not(stage0))]
|
||||
pub unsafe fn uninit<T>() -> T;
|
||||
|
||||
/// Move a value out of scope without running drop glue.
|
||||
|
@ -268,15 +268,6 @@ pub unsafe fn local_free(ptr: *c_char) {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
#[lang="borrow_as_imm"]
|
||||
#[inline(always)]
|
||||
pub unsafe fn borrow_as_imm(a: *u8) {
|
||||
let a: *mut BoxRepr = transmute(a);
|
||||
(*a).header.ref_count |= FROZEN_BIT;
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
#[lang="borrow_as_imm"]
|
||||
#[inline(always)]
|
||||
pub unsafe fn borrow_as_imm(a: *u8, file: *c_char, line: size_t) -> uint {
|
||||
@ -295,7 +286,6 @@ pub unsafe fn borrow_as_imm(a: *u8, file: *c_char, line: size_t) -> uint {
|
||||
old_ref_count
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
#[lang="borrow_as_mut"]
|
||||
#[inline(always)]
|
||||
pub unsafe fn borrow_as_mut(a: *u8, file: *c_char, line: size_t) -> uint {
|
||||
@ -315,7 +305,6 @@ pub unsafe fn borrow_as_mut(a: *u8, file: *c_char, line: size_t) -> uint {
|
||||
}
|
||||
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
#[lang="record_borrow"]
|
||||
pub unsafe fn record_borrow(a: *u8, old_ref_count: uint,
|
||||
file: *c_char, line: size_t) {
|
||||
@ -331,7 +320,6 @@ pub unsafe fn record_borrow(a: *u8, old_ref_count: uint,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
#[lang="unrecord_borrow"]
|
||||
pub unsafe fn unrecord_borrow(a: *u8, old_ref_count: uint,
|
||||
file: *c_char, line: size_t) {
|
||||
@ -355,19 +343,6 @@ pub unsafe fn unrecord_borrow(a: *u8, old_ref_count: uint,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
#[lang="return_to_mut"]
|
||||
#[inline(always)]
|
||||
pub unsafe fn return_to_mut(a: *u8) {
|
||||
// Sometimes the box is null, if it is conditionally frozen.
|
||||
// See e.g. #4904.
|
||||
if !a.is_null() {
|
||||
let a: *mut BoxRepr = transmute(a);
|
||||
(*a).header.ref_count &= !FROZEN_BIT;
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
#[lang="return_to_mut"]
|
||||
#[inline(always)]
|
||||
pub unsafe fn return_to_mut(a: *u8, orig_ref_count: uint,
|
||||
@ -387,19 +362,6 @@ pub unsafe fn return_to_mut(a: *u8, orig_ref_count: uint,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
#[lang="check_not_borrowed"]
|
||||
#[inline(always)]
|
||||
pub unsafe fn check_not_borrowed(a: *u8) {
|
||||
let a: *mut BoxRepr = transmute(a);
|
||||
if ((*a).header.ref_count & FROZEN_BIT) != 0 {
|
||||
do str::as_buf("XXX") |file_p, _| {
|
||||
fail_borrowed(a, file_p as *c_char, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
#[lang="check_not_borrowed"]
|
||||
#[inline(always)]
|
||||
pub unsafe fn check_not_borrowed(a: *u8,
|
||||
|
@ -41,18 +41,6 @@ impl<T: Owned> UnsafeAtomicRcBox<T> {
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[cfg(stage0)]
|
||||
pub unsafe fn get(&self) -> *mut T
|
||||
{
|
||||
let mut data: ~AtomicRcBoxData<T> = cast::transmute(self.data);
|
||||
assert!(data.count > 0);
|
||||
let r: *mut T = cast::transmute(data.data.get_mut_ref());
|
||||
cast::forget(data);
|
||||
return r;
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[cfg(not(stage0))]
|
||||
pub unsafe fn get(&self) -> *mut T
|
||||
{
|
||||
let mut data: ~AtomicRcBoxData<T> = cast::transmute(self.data);
|
||||
@ -63,18 +51,6 @@ impl<T: Owned> UnsafeAtomicRcBox<T> {
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[cfg(stage0)]
|
||||
pub unsafe fn get_immut(&self) -> *T
|
||||
{
|
||||
let mut data: ~AtomicRcBoxData<T> = cast::transmute(self.data);
|
||||
assert!(data.count > 0);
|
||||
let r: *T = cast::transmute(data.data.get_mut_ref());
|
||||
cast::forget(data);
|
||||
return r;
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[cfg(not(stage0))]
|
||||
pub unsafe fn get_immut(&self) -> *T
|
||||
{
|
||||
let mut data: ~AtomicRcBoxData<T> = cast::transmute(self.data);
|
||||
|
@ -60,7 +60,6 @@ pub fn swap<T>(x: &mut T, y: &mut T) {
|
||||
* deinitialising or copying either one.
|
||||
*/
|
||||
#[inline]
|
||||
#[cfg(not(stage0))]
|
||||
pub unsafe fn swap_ptr<T>(x: *mut T, y: *mut T) {
|
||||
if x == y { return }
|
||||
|
||||
@ -78,29 +77,6 @@ pub unsafe fn swap_ptr<T>(x: *mut T, y: *mut T) {
|
||||
cast::forget(tmp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Swap the values at two mutable locations of the same type, without
|
||||
* deinitialising or copying either one.
|
||||
*/
|
||||
#[inline]
|
||||
#[cfg(stage0)]
|
||||
pub unsafe fn swap_ptr<T>(x: *mut T, y: *mut T) {
|
||||
if x == y { return }
|
||||
|
||||
// Give ourselves some scratch space to work with
|
||||
let mut tmp: T = intrinsics::init();
|
||||
let t = ptr::to_mut_unsafe_ptr(&mut tmp);
|
||||
|
||||
// Perform the swap
|
||||
ptr::copy_memory(t, x, 1);
|
||||
ptr::copy_memory(x, y, 1);
|
||||
ptr::copy_memory(y, t, 1);
|
||||
|
||||
// y and t now point to the same thing, but we need to completely forget t
|
||||
// because it's no longer relevant.
|
||||
cast::forget(tmp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace the value at a mutable location with a new one, returning the old
|
||||
* value, without deinitialising or copying either one.
|
||||
|
@ -583,21 +583,6 @@ pub fn consume_reverse<T>(mut v: ~[T], f: &fn(uint, v: T)) {
|
||||
}
|
||||
|
||||
/// Remove the last element from a vector and return it
|
||||
#[cfg(not(stage0))]
|
||||
pub fn pop<T>(v: &mut ~[T]) -> T {
|
||||
let ln = v.len();
|
||||
if ln == 0 {
|
||||
fail!("sorry, cannot vec::pop an empty vector")
|
||||
}
|
||||
let valptr = ptr::to_mut_unsafe_ptr(&mut v[ln - 1u]);
|
||||
unsafe {
|
||||
let val = util::replace_ptr(valptr, intrinsics::uninit());
|
||||
raw::set_len(v, ln - 1u);
|
||||
val
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub fn pop<T>(v: &mut ~[T]) -> T {
|
||||
let ln = v.len();
|
||||
if ln == 0 {
|
||||
@ -672,7 +657,6 @@ pub fn push_all<T:Copy>(v: &mut ~[T], rhs: &const [T]) {
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[cfg(not(stage0))]
|
||||
pub fn push_all_move<T>(v: &mut ~[T], mut rhs: ~[T]) {
|
||||
let new_len = v.len() + rhs.len();
|
||||
reserve(&mut *v, new_len);
|
||||
@ -688,25 +672,7 @@ pub fn push_all_move<T>(v: &mut ~[T], mut rhs: ~[T]) {
|
||||
}
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[cfg(stage0)]
|
||||
pub fn push_all_move<T>(v: &mut ~[T], mut rhs: ~[T]) {
|
||||
let new_len = v.len() + rhs.len();
|
||||
reserve(&mut *v, new_len);
|
||||
unsafe {
|
||||
do as_mut_buf(rhs) |p, len| {
|
||||
for uint::range(0, len) |i| {
|
||||
let x = util::replace_ptr(ptr::mut_offset(p, i),
|
||||
intrinsics::init());
|
||||
push(&mut *v, x);
|
||||
}
|
||||
}
|
||||
raw::set_len(&mut rhs, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/// Shorten a vector, dropping excess elements.
|
||||
#[cfg(not(stage0))]
|
||||
pub fn truncate<T>(v: &mut ~[T], newlen: uint) {
|
||||
do as_mut_buf(*v) |p, oldlen| {
|
||||
assert!(newlen <= oldlen);
|
||||
@ -720,26 +686,10 @@ pub fn truncate<T>(v: &mut ~[T], newlen: uint) {
|
||||
unsafe { raw::set_len(&mut *v, newlen); }
|
||||
}
|
||||
|
||||
/// Shorten a vector, dropping excess elements.
|
||||
#[cfg(stage0)]
|
||||
pub fn truncate<T>(v: &mut ~[T], newlen: uint) {
|
||||
do as_mut_buf(*v) |p, oldlen| {
|
||||
assert!(newlen <= oldlen);
|
||||
unsafe {
|
||||
// This loop is optimized out for non-drop types.
|
||||
for uint::range(newlen, oldlen) |i| {
|
||||
util::replace_ptr(ptr::mut_offset(p, i), intrinsics::init());
|
||||
}
|
||||
}
|
||||
}
|
||||
unsafe { raw::set_len(&mut *v, newlen); }
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove consecutive repeated elements from a vector; if the vector is
|
||||
* sorted, this removes all duplicates.
|
||||
*/
|
||||
#[cfg(not(stage0))]
|
||||
pub fn dedup<T:Eq>(v: &mut ~[T]) {
|
||||
unsafe {
|
||||
if v.len() < 1 { return; }
|
||||
@ -773,45 +723,6 @@ pub fn dedup<T:Eq>(v: &mut ~[T]) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove consecutive repeated elements from a vector; if the vector is
|
||||
* sorted, this removes all duplicates.
|
||||
*/
|
||||
#[cfg(stage0)]
|
||||
pub fn dedup<T:Eq>(v: &mut ~[T]) {
|
||||
unsafe {
|
||||
if v.len() < 1 { return; }
|
||||
let mut last_written = 0, next_to_read = 1;
|
||||
do as_const_buf(*v) |p, ln| {
|
||||
// We have a mutable reference to v, so we can make arbitrary
|
||||
// changes. (cf. push and pop)
|
||||
let p = p as *mut T;
|
||||
// last_written < next_to_read <= ln
|
||||
while next_to_read < ln {
|
||||
// last_written < next_to_read < ln
|
||||
if *ptr::mut_offset(p, next_to_read) ==
|
||||
*ptr::mut_offset(p, last_written) {
|
||||
util::replace_ptr(ptr::mut_offset(p, next_to_read),
|
||||
intrinsics::init());
|
||||
} else {
|
||||
last_written += 1;
|
||||
// last_written <= next_to_read < ln
|
||||
if next_to_read != last_written {
|
||||
util::swap_ptr(ptr::mut_offset(p, last_written),
|
||||
ptr::mut_offset(p, next_to_read));
|
||||
}
|
||||
}
|
||||
// last_written <= next_to_read < ln
|
||||
next_to_read += 1;
|
||||
// last_written < next_to_read <= ln
|
||||
}
|
||||
}
|
||||
// last_written < next_to_read == ln
|
||||
raw::set_len(v, last_written + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Appending
|
||||
#[inline(always)]
|
||||
pub fn append<T:Copy>(lhs: ~[T], rhs: &const [T]) -> ~[T] {
|
||||
@ -1557,9 +1468,6 @@ pub fn _each<'r,T>(v: &'r [T], f: &fn(&'r T) -> bool) -> bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub fn each<'r,T>(v: &'r [T], f: &fn(&'r T) -> bool) { _each(v, f); }
|
||||
#[cfg(not(stage0))]
|
||||
pub fn each<'r,T>(v: &'r [T], f: &fn(&'r T) -> bool) -> bool { _each(v, f) }
|
||||
|
||||
/// Like `each()`, but for the case where you have
|
||||
@ -1584,11 +1492,6 @@ pub fn _each_mut<'r,T>(v: &'r mut [T], f: &fn(elem: &'r mut T) -> bool) -> bool
|
||||
return broke;
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub fn each_mut<'r,T>(v: &'r mut [T], f: &fn(elem: &'r mut T) -> bool) {
|
||||
_each_mut(v, f);
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
pub fn each_mut<'r,T>(v: &'r mut [T], f: &fn(elem: &'r mut T) -> bool) -> bool {
|
||||
_each_mut(v, f)
|
||||
}
|
||||
@ -1608,11 +1511,6 @@ pub fn _each_const<T>(v: &const [T], f: &fn(elem: &const T) -> bool) -> bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub fn each_const<t>(v: &const [t], f: &fn(elem: &const t) -> bool) {
|
||||
_each_const(v, f);
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
pub fn each_const<t>(v: &const [t], f: &fn(elem: &const t) -> bool) -> bool {
|
||||
_each_const(v, f)
|
||||
}
|
||||
@ -1632,9 +1530,6 @@ pub fn _eachi<'r,T>(v: &'r [T], f: &fn(uint, v: &'r T) -> bool) -> bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub fn eachi<'r,T>(v: &'r [T], f: &fn(uint, v: &'r T) -> bool) { _eachi(v, f); }
|
||||
#[cfg(not(stage0))]
|
||||
pub fn eachi<'r,T>(v: &'r [T], f: &fn(uint, v: &'r T) -> bool) -> bool {
|
||||
_eachi(v, f)
|
||||
}
|
||||
@ -1657,11 +1552,6 @@ pub fn _eachi_mut<'r,T>(v: &'r mut [T],
|
||||
return true;
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub fn eachi_mut<'r,T>(v: &'r mut [T], f: &fn(uint, v: &'r mut T) -> bool) {
|
||||
_eachi_mut(v, f);
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
pub fn eachi_mut<'r,T>(v: &'r mut [T],
|
||||
f: &fn(uint, v: &'r mut T) -> bool) -> bool {
|
||||
_eachi_mut(v, f)
|
||||
@ -1677,11 +1567,6 @@ pub fn _each_reverse<'r,T>(v: &'r [T], blk: &fn(v: &'r T) -> bool) -> bool {
|
||||
_eachi_reverse(v, |_i, v| blk(v))
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub fn each_reverse<'r,T>(v: &'r [T], blk: &fn(v: &'r T) -> bool) {
|
||||
_each_reverse(v, blk);
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
pub fn each_reverse<'r,T>(v: &'r [T], blk: &fn(v: &'r T) -> bool) -> bool {
|
||||
_each_reverse(v, blk)
|
||||
}
|
||||
@ -1704,11 +1589,6 @@ pub fn _eachi_reverse<'r,T>(v: &'r [T],
|
||||
return true;
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub fn eachi_reverse<'r,T>(v: &'r [T], blk: &fn(i: uint, v: &'r T) -> bool) {
|
||||
_eachi_reverse(v, blk);
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
pub fn eachi_reverse<'r,T>(v: &'r [T],
|
||||
blk: &fn(i: uint, v: &'r T) -> bool) -> bool {
|
||||
_eachi_reverse(v, blk)
|
||||
@ -1732,11 +1612,6 @@ pub fn _each2<U, T>(v1: &[U], v2: &[T], f: &fn(u: &U, t: &T) -> bool) -> bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub fn each2<U, T>(v1: &[U], v2: &[T], f: &fn(u: &U, t: &T) -> bool) {
|
||||
_each2(v1, v2, f);
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
pub fn each2<U, T>(v1: &[U], v2: &[T], f: &fn(u: &U, t: &T) -> bool) -> bool {
|
||||
_each2(v1, v2, f)
|
||||
}
|
||||
@ -1760,12 +1635,6 @@ pub fn _each2_mut<U, T>(v1: &mut [U], v2: &mut [T], f: &fn(u: &mut U, t: &mut T)
|
||||
return true;
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub fn each2_mut<U, T>(v1: &mut [U], v2: &mut [T], f: &fn(u: &mut U, t: &mut T) -> bool) {
|
||||
_each2_mut(v1, v2, f);
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
pub fn each2_mut<U, T>(v1: &mut [U], v2: &mut [T], f: &fn(u: &mut U, t: &mut T) -> bool) -> bool {
|
||||
_each2_mut(v1, v2, f)
|
||||
}
|
||||
@ -1838,29 +1707,6 @@ pub fn each_permutation<T:Copy>(values: &[T], fun: &fn(perm : &[T]) -> bool) ->
|
||||
* ~~~
|
||||
*
|
||||
*/
|
||||
#[cfg(stage0)]
|
||||
pub fn windowed<'r, T>(n: uint, v: &'r [T], it: &fn(&'r [T]) -> bool) {
|
||||
assert!(1u <= n);
|
||||
if n > v.len() { return; }
|
||||
for uint::range(0, v.len() - n + 1) |i| {
|
||||
if !it(v.slice(i, i + n)) { return }
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Iterate over all contiguous windows of length `n` of the vector `v`.
|
||||
*
|
||||
* # Example
|
||||
*
|
||||
* Print the adjacent pairs of a vector (i.e. `[1,2]`, `[2,3]`, `[3,4]`)
|
||||
*
|
||||
* ~~~
|
||||
* for windowed(2, &[1,2,3,4]) |v| {
|
||||
* io::println(fmt!("%?", v));
|
||||
* }
|
||||
* ~~~
|
||||
*
|
||||
*/
|
||||
#[cfg(not(stage0))]
|
||||
pub fn windowed<'r, T>(n: uint, v: &'r [T], it: &fn(&'r [T]) -> bool) -> bool {
|
||||
assert!(1u <= n);
|
||||
if n > v.len() { return true; }
|
||||
@ -2133,13 +1979,7 @@ pub trait ImmutableVector<'self, T> {
|
||||
fn last_opt(&self) -> Option<&'self T>;
|
||||
fn position(&self, f: &fn(t: &T) -> bool) -> Option<uint>;
|
||||
fn rposition(&self, f: &fn(t: &T) -> bool) -> Option<uint>;
|
||||
#[cfg(stage0)]
|
||||
fn each_reverse(&self, blk: &fn(&T) -> bool);
|
||||
#[cfg(not(stage0))]
|
||||
fn each_reverse(&self, blk: &fn(&T) -> bool) -> bool;
|
||||
#[cfg(stage0)]
|
||||
fn eachi_reverse(&self, blk: &fn(uint, &T) -> bool);
|
||||
#[cfg(not(stage0))]
|
||||
fn eachi_reverse(&self, blk: &fn(uint, &T) -> bool) -> bool;
|
||||
fn foldr<'a, U>(&'a self, z: U, p: &fn(t: &'a T, u: U) -> U) -> U;
|
||||
fn map<U>(&self, f: &fn(t: &T) -> U) -> ~[U];
|
||||
@ -2226,25 +2066,11 @@ impl<'self,T> ImmutableVector<'self, T> for &'self [T] {
|
||||
|
||||
/// Iterates over a vector's elements in reverse.
|
||||
#[inline]
|
||||
#[cfg(stage0)]
|
||||
fn each_reverse(&self, blk: &fn(&T) -> bool) {
|
||||
each_reverse(*self, blk)
|
||||
}
|
||||
/// Iterates over a vector's elements in reverse.
|
||||
#[inline]
|
||||
#[cfg(not(stage0))]
|
||||
fn each_reverse(&self, blk: &fn(&T) -> bool) -> bool {
|
||||
each_reverse(*self, blk)
|
||||
}
|
||||
|
||||
/// Iterates over a vector's elements and indices in reverse.
|
||||
#[cfg(stage0)]
|
||||
#[inline]
|
||||
fn eachi_reverse(&self, blk: &fn(uint, &T) -> bool) {
|
||||
eachi_reverse(*self, blk)
|
||||
}
|
||||
/// Iterates over a vector's elements and indices in reverse.
|
||||
#[cfg(not(stage0))]
|
||||
#[inline]
|
||||
fn eachi_reverse(&self, blk: &fn(uint, &T) -> bool) -> bool {
|
||||
eachi_reverse(*self, blk)
|
||||
@ -2780,12 +2606,6 @@ pub mod bytes {
|
||||
// ITERATION TRAIT METHODS
|
||||
|
||||
impl<'self,A> old_iter::BaseIter<A> for &'self [A] {
|
||||
#[cfg(stage0)]
|
||||
#[inline(always)]
|
||||
fn each<'a>(&'a self, blk: &fn(v: &'a A) -> bool) {
|
||||
each(*self, blk)
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
#[inline(always)]
|
||||
fn each<'a>(&'a self, blk: &fn(v: &'a A) -> bool) -> bool {
|
||||
each(*self, blk)
|
||||
@ -2796,12 +2616,6 @@ impl<'self,A> old_iter::BaseIter<A> for &'self [A] {
|
||||
|
||||
// FIXME(#4148): This should be redundant
|
||||
impl<A> old_iter::BaseIter<A> for ~[A] {
|
||||
#[cfg(stage0)]
|
||||
#[inline(always)]
|
||||
fn each<'a>(&'a self, blk: &fn(v: &'a A) -> bool) {
|
||||
each(*self, blk)
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
#[inline(always)]
|
||||
fn each<'a>(&'a self, blk: &fn(v: &'a A) -> bool) -> bool {
|
||||
each(*self, blk)
|
||||
@ -2812,12 +2626,6 @@ impl<A> old_iter::BaseIter<A> for ~[A] {
|
||||
|
||||
// FIXME(#4148): This should be redundant
|
||||
impl<A> old_iter::BaseIter<A> for @[A] {
|
||||
#[cfg(stage0)]
|
||||
#[inline(always)]
|
||||
fn each<'a>(&'a self, blk: &fn(v: &'a A) -> bool) {
|
||||
each(*self, blk)
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
#[inline(always)]
|
||||
fn each<'a>(&'a self, blk: &fn(v: &'a A) -> bool) -> bool {
|
||||
each(*self, blk)
|
||||
@ -2827,12 +2635,6 @@ impl<A> old_iter::BaseIter<A> for @[A] {
|
||||
}
|
||||
|
||||
impl<'self,A> old_iter::MutableIter<A> for &'self mut [A] {
|
||||
#[cfg(stage0)]
|
||||
#[inline(always)]
|
||||
fn each_mut<'a>(&'a mut self, blk: &fn(v: &'a mut A) -> bool) {
|
||||
each_mut(*self, blk)
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
#[inline(always)]
|
||||
fn each_mut<'a>(&'a mut self, blk: &fn(v: &'a mut A) -> bool) -> bool {
|
||||
each_mut(*self, blk)
|
||||
@ -2841,12 +2643,6 @@ impl<'self,A> old_iter::MutableIter<A> for &'self mut [A] {
|
||||
|
||||
// FIXME(#4148): This should be redundant
|
||||
impl<A> old_iter::MutableIter<A> for ~[A] {
|
||||
#[cfg(stage0)]
|
||||
#[inline(always)]
|
||||
fn each_mut<'a>(&'a mut self, blk: &fn(v: &'a mut A) -> bool) {
|
||||
each_mut(*self, blk)
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
#[inline(always)]
|
||||
fn each_mut<'a>(&'a mut self, blk: &fn(v: &'a mut A) -> bool) -> bool {
|
||||
each_mut(*self, blk)
|
||||
@ -2854,15 +2650,6 @@ impl<A> old_iter::MutableIter<A> for ~[A] {
|
||||
}
|
||||
|
||||
// FIXME(#4148): This should be redundant
|
||||
#[cfg(stage0)]
|
||||
impl<A> old_iter::MutableIter<A> for @mut [A] {
|
||||
#[inline(always)]
|
||||
fn each_mut(&mut self, blk: &fn(v: &mut A) -> bool) {
|
||||
each_mut(*self, blk)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
impl<A> old_iter::MutableIter<A> for @mut [A] {
|
||||
#[inline(always)]
|
||||
fn each_mut(&mut self, blk: &fn(v: &mut A) -> bool) -> bool {
|
||||
@ -2871,11 +2658,6 @@ impl<A> old_iter::MutableIter<A> for @mut [A] {
|
||||
}
|
||||
|
||||
impl<'self,A> old_iter::ExtendedIter<A> for &'self [A] {
|
||||
#[cfg(stage0)]
|
||||
pub fn eachi(&self, blk: &fn(uint, v: &A) -> bool) {
|
||||
old_iter::eachi(self, blk)
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
pub fn eachi(&self, blk: &fn(uint, v: &A) -> bool) -> bool {
|
||||
old_iter::eachi(self, blk)
|
||||
}
|
||||
@ -2902,12 +2684,6 @@ impl<'self,A> old_iter::ExtendedIter<A> for &'self [A] {
|
||||
|
||||
impl<'self,A> old_iter::ExtendedMutableIter<A> for &'self mut [A] {
|
||||
#[inline(always)]
|
||||
#[cfg(stage0)]
|
||||
pub fn eachi_mut(&mut self, blk: &fn(uint, v: &mut A) -> bool) {
|
||||
eachi_mut(*self, blk)
|
||||
}
|
||||
#[inline(always)]
|
||||
#[cfg(not(stage0))]
|
||||
pub fn eachi_mut(&mut self, blk: &fn(uint, v: &mut A) -> bool) -> bool {
|
||||
eachi_mut(*self, blk)
|
||||
}
|
||||
@ -2915,11 +2691,6 @@ impl<'self,A> old_iter::ExtendedMutableIter<A> for &'self mut [A] {
|
||||
|
||||
// FIXME(#4148): This should be redundant
|
||||
impl<A> old_iter::ExtendedIter<A> for ~[A] {
|
||||
#[cfg(stage0)]
|
||||
pub fn eachi(&self, blk: &fn(uint, v: &A) -> bool) {
|
||||
old_iter::eachi(self, blk)
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
pub fn eachi(&self, blk: &fn(uint, v: &A) -> bool) -> bool {
|
||||
old_iter::eachi(self, blk)
|
||||
}
|
||||
@ -2946,11 +2717,6 @@ impl<A> old_iter::ExtendedIter<A> for ~[A] {
|
||||
|
||||
// FIXME(#4148): This should be redundant
|
||||
impl<A> old_iter::ExtendedIter<A> for @[A] {
|
||||
#[cfg(stage0)]
|
||||
pub fn eachi(&self, blk: &fn(uint, v: &A) -> bool) {
|
||||
old_iter::eachi(self, blk)
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
pub fn eachi(&self, blk: &fn(uint, v: &A) -> bool) -> bool {
|
||||
old_iter::eachi(self, blk)
|
||||
}
|
||||
|
@ -44,15 +44,6 @@ pub fn get_type_param_count(cstore: @mut cstore::CStore, def: ast::def_id)
|
||||
}
|
||||
|
||||
/// Iterates over all the language items in the given crate.
|
||||
#[cfg(stage0)]
|
||||
pub fn each_lang_item(cstore: @mut cstore::CStore,
|
||||
cnum: ast::crate_num,
|
||||
f: &fn(ast::node_id, uint) -> bool) {
|
||||
let crate_data = cstore::get_crate_data(cstore, cnum);
|
||||
decoder::each_lang_item(crate_data, f)
|
||||
}
|
||||
/// Iterates over all the language items in the given crate.
|
||||
#[cfg(not(stage0))]
|
||||
pub fn each_lang_item(cstore: @mut cstore::CStore,
|
||||
cnum: ast::crate_num,
|
||||
f: &fn(ast::node_id, uint) -> bool) -> bool {
|
||||
@ -61,18 +52,6 @@ pub fn each_lang_item(cstore: @mut cstore::CStore,
|
||||
}
|
||||
|
||||
/// Iterates over all the paths in the given crate.
|
||||
#[cfg(stage0)]
|
||||
pub fn each_path(cstore: @mut cstore::CStore,
|
||||
cnum: ast::crate_num,
|
||||
f: &fn(&str, decoder::def_like) -> bool) {
|
||||
let crate_data = cstore::get_crate_data(cstore, cnum);
|
||||
let get_crate_data: decoder::GetCrateDataCb = |cnum| {
|
||||
cstore::get_crate_data(cstore, cnum)
|
||||
};
|
||||
decoder::each_path(cstore.intr, crate_data, get_crate_data, f);
|
||||
}
|
||||
/// Iterates over all the paths in the given crate.
|
||||
#[cfg(not(stage0))]
|
||||
pub fn each_path(cstore: @mut cstore::CStore,
|
||||
cnum: ast::crate_num,
|
||||
f: &fn(&str, decoder::def_like) -> bool) -> bool {
|
||||
|
@ -196,15 +196,6 @@ fn item_def_id(d: ebml::Doc, cdata: cmd) -> ast::def_id {
|
||||
|d| parse_def_id(d)));
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
fn each_reexport(d: ebml::Doc, f: &fn(ebml::Doc) -> bool) {
|
||||
for reader::tagged_docs(d, tag_items_data_item_reexport) |reexport_doc| {
|
||||
if !f(reexport_doc) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
fn each_reexport(d: ebml::Doc, f: &fn(ebml::Doc) -> bool) -> bool {
|
||||
for reader::tagged_docs(d, tag_items_data_item_reexport) |reexport_doc| {
|
||||
if !f(reexport_doc) {
|
||||
@ -465,24 +456,6 @@ fn def_like_to_def(def_like: def_like) -> ast::def {
|
||||
}
|
||||
|
||||
/// Iterates over the language items in the given crate.
|
||||
#[cfg(stage0)]
|
||||
pub fn each_lang_item(cdata: cmd, f: &fn(ast::node_id, uint) -> bool) {
|
||||
let root = reader::Doc(cdata.data);
|
||||
let lang_items = reader::get_doc(root, tag_lang_items);
|
||||
for reader::tagged_docs(lang_items, tag_lang_items_item) |item_doc| {
|
||||
let id_doc = reader::get_doc(item_doc, tag_lang_items_item_id);
|
||||
let id = reader::doc_as_u32(id_doc) as uint;
|
||||
let node_id_doc = reader::get_doc(item_doc,
|
||||
tag_lang_items_item_node_id);
|
||||
let node_id = reader::doc_as_u32(node_id_doc) as ast::node_id;
|
||||
|
||||
if !f(node_id, id) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// Iterates over the language items in the given crate.
|
||||
#[cfg(not(stage0))]
|
||||
pub fn each_lang_item(cdata: cmd, f: &fn(ast::node_id, uint) -> bool) -> bool {
|
||||
let root = reader::Doc(cdata.data);
|
||||
let lang_items = reader::get_doc(root, tag_lang_items);
|
||||
@ -588,13 +561,6 @@ pub fn _each_path(intr: @ident_interner, cdata: cmd,
|
||||
return broken;
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub fn each_path(intr: @ident_interner, cdata: cmd,
|
||||
get_crate_data: GetCrateDataCb,
|
||||
f: &fn(&str, def_like) -> bool) {
|
||||
_each_path(intr, cdata, get_crate_data, f);
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
pub fn each_path(intr: @ident_interner, cdata: cmd,
|
||||
get_crate_data: GetCrateDataCb,
|
||||
f: &fn(&str, def_like) -> bool) -> bool {
|
||||
|
@ -21,9 +21,6 @@ pub fn pick_file(file: Path, path: &Path) -> Option<Path> {
|
||||
|
||||
pub trait FileSearch {
|
||||
fn sysroot(&self) -> @Path;
|
||||
#[cfg(stage0)]
|
||||
fn for_each_lib_search_path(&self, f: &fn(&Path) -> bool);
|
||||
#[cfg(not(stage0))]
|
||||
fn for_each_lib_search_path(&self, f: &fn(&Path) -> bool) -> bool;
|
||||
fn get_target_lib_path(&self) -> Path;
|
||||
fn get_target_lib_file_path(&self, file: &Path) -> Path;
|
||||
@ -40,31 +37,6 @@ pub fn mk_filesearch(maybe_sysroot: &Option<@Path>,
|
||||
}
|
||||
impl FileSearch for FileSearchImpl {
|
||||
fn sysroot(&self) -> @Path { self.sysroot }
|
||||
#[cfg(stage0)]
|
||||
fn for_each_lib_search_path(&self, f: &fn(&Path) -> bool) {
|
||||
debug!("filesearch: searching additional lib search paths");
|
||||
// a little weird
|
||||
self.addl_lib_search_paths.each(f);
|
||||
|
||||
debug!("filesearch: searching target lib path");
|
||||
if !f(&make_target_lib_path(self.sysroot,
|
||||
self.target_triple)) {
|
||||
return;
|
||||
}
|
||||
debug!("filesearch: searching rustpkg lib path nearest");
|
||||
if match get_rustpkg_lib_path_nearest() {
|
||||
result::Ok(ref p) => f(p),
|
||||
result::Err(_) => true
|
||||
} {
|
||||
return;
|
||||
}
|
||||
debug!("filesearch: searching rustpkg lib path");
|
||||
match get_rustpkg_lib_path() {
|
||||
result::Ok(ref p) => f(p),
|
||||
result::Err(_) => true
|
||||
};
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
fn for_each_lib_search_path(&self, f: &fn(&Path) -> bool) -> bool {
|
||||
debug!("filesearch: searching additional lib search paths");
|
||||
// a little weird
|
||||
|
@ -67,25 +67,6 @@ enum MoveError {
|
||||
pub impl<'self> CheckLoanCtxt<'self> {
|
||||
fn tcx(&self) -> ty::ctxt { self.bccx.tcx }
|
||||
|
||||
#[cfg(stage0)]
|
||||
fn each_issued_loan(&self,
|
||||
scope_id: ast::node_id,
|
||||
op: &fn(&Loan) -> bool)
|
||||
{
|
||||
//! Iterates over each loan that that has been issued
|
||||
//! on entrance to `scope_id`, regardless of whether it is
|
||||
//! actually *in scope* at that point. Sometimes loans
|
||||
//! are issued for future scopes and thus they may have been
|
||||
//! *issued* but not yet be in effect.
|
||||
|
||||
for self.dfcx.each_bit_on_entry(scope_id) |loan_index| {
|
||||
let loan = &self.all_loans[loan_index];
|
||||
if !op(loan) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
fn each_issued_loan(&self,
|
||||
scope_id: ast::node_id,
|
||||
op: &fn(&Loan) -> bool) -> bool
|
||||
@ -105,24 +86,6 @@ pub impl<'self> CheckLoanCtxt<'self> {
|
||||
return true;
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
fn each_in_scope_loan(&self,
|
||||
scope_id: ast::node_id,
|
||||
op: &fn(&Loan) -> bool)
|
||||
{
|
||||
//! Like `each_issued_loan()`, but only considers loans that are
|
||||
//! currently in scope.
|
||||
|
||||
let region_maps = self.tcx().region_maps;
|
||||
for self.each_issued_loan(scope_id) |loan| {
|
||||
if region_maps.is_subscope_of(scope_id, loan.kill_scope) {
|
||||
if !op(loan) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
fn each_in_scope_loan(&self,
|
||||
scope_id: ast::node_id,
|
||||
op: &fn(&Loan) -> bool) -> bool
|
||||
@ -141,26 +104,6 @@ pub impl<'self> CheckLoanCtxt<'self> {
|
||||
return true;
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
fn each_in_scope_restriction(&self,
|
||||
scope_id: ast::node_id,
|
||||
loan_path: @LoanPath,
|
||||
op: &fn(&Loan, &Restriction) -> bool)
|
||||
{
|
||||
//! Iterates through all the in-scope restrictions for the
|
||||
//! given `loan_path`
|
||||
|
||||
for self.each_in_scope_loan(scope_id) |loan| {
|
||||
for loan.restrictions.each |restr| {
|
||||
if restr.loan_path == loan_path {
|
||||
if !op(loan, restr) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
fn each_in_scope_restriction(&self,
|
||||
scope_id: ast::node_id,
|
||||
loan_path: @LoanPath,
|
||||
|
@ -19,8 +19,6 @@ use middle::dataflow::DataFlowOperator;
|
||||
use util::common::stmt_set;
|
||||
use util::ppaux::{note_and_explain_region, Repr};
|
||||
|
||||
#[cfg(stage0)]
|
||||
use core; // NOTE: this can be removed after the next snapshot
|
||||
use core::hashmap::{HashSet, HashMap};
|
||||
use core::io;
|
||||
use core::result::{Result};
|
||||
|
@ -181,20 +181,6 @@ impl<O:DataFlowOperator> DataFlowContext<O> {
|
||||
}
|
||||
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub fn each_bit_on_entry(&self,
|
||||
id: ast::node_id,
|
||||
f: &fn(uint) -> bool) {
|
||||
//! Iterates through each bit that is set on entry to `id`.
|
||||
//! Only useful after `propagate()` has been called.
|
||||
|
||||
let (start, end) = self.compute_id_range(id);
|
||||
let on_entry = vec::slice(self.on_entry, start, end);
|
||||
debug!("each_bit_on_entry(id=%?, on_entry=%s)",
|
||||
id, bits_to_str(on_entry));
|
||||
self.each_bit(on_entry, f);
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
pub fn each_bit_on_entry(&self,
|
||||
id: ast::node_id,
|
||||
f: &fn(uint) -> bool) -> bool {
|
||||
@ -208,19 +194,6 @@ impl<O:DataFlowOperator> DataFlowContext<O> {
|
||||
self.each_bit(on_entry, f)
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub fn each_gen_bit(&self,
|
||||
id: ast::node_id,
|
||||
f: &fn(uint) -> bool) {
|
||||
//! Iterates through each bit in the gen set for `id`.
|
||||
|
||||
let (start, end) = self.compute_id_range(id);
|
||||
let gens = vec::slice(self.gens, start, end);
|
||||
debug!("each_gen_bit(id=%?, gens=%s)",
|
||||
id, bits_to_str(gens));
|
||||
self.each_bit(gens, f)
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
pub fn each_gen_bit(&self,
|
||||
id: ast::node_id,
|
||||
f: &fn(uint) -> bool) -> bool {
|
||||
@ -233,37 +206,6 @@ impl<O:DataFlowOperator> DataFlowContext<O> {
|
||||
self.each_bit(gens, f)
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
fn each_bit(&self,
|
||||
words: &[uint],
|
||||
f: &fn(uint) -> bool) {
|
||||
//! Helper for iterating over the bits in a bit set.
|
||||
|
||||
for words.eachi |word_index, &word| {
|
||||
if word != 0 {
|
||||
let base_index = word_index * uint::bits;
|
||||
for uint::range(0, uint::bits) |offset| {
|
||||
let bit = 1 << offset;
|
||||
if (word & bit) != 0 {
|
||||
// NB: we round up the total number of bits
|
||||
// that we store in any given bit set so that
|
||||
// it is an even multiple of uint::bits. This
|
||||
// means that there may be some stray bits at
|
||||
// the end that do not correspond to any
|
||||
// actual value. So before we callback, check
|
||||
// whether the bit_index is greater than the
|
||||
// actual value the user specified and stop
|
||||
// iterating if so.
|
||||
let bit_index = base_index + offset;
|
||||
if bit_index >= self.bits_per_id || !f(bit_index) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
fn each_bit(&self,
|
||||
words: &[uint],
|
||||
f: &fn(uint) -> bool) -> bool {
|
||||
|
@ -86,15 +86,6 @@ pub impl LanguageItems {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
fn each_item(&self, f: &fn(def_id: def_id, i: uint) -> bool) {
|
||||
for self.items.eachi |i, &item| {
|
||||
if !f(item.get(), i) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
fn each_item(&self, f: &fn(def_id: def_id, i: uint) -> bool) -> bool {
|
||||
self.items.eachi(|i, &item| f(item.get(), i))
|
||||
}
|
||||
|
@ -419,39 +419,6 @@ impl Context {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub fn each_lint(sess: session::Session,
|
||||
attrs: &[ast::attribute],
|
||||
f: &fn(@ast::meta_item, level, &~str) -> bool)
|
||||
{
|
||||
for [allow, warn, deny, forbid].each |&level| {
|
||||
let level_name = level_to_str(level);
|
||||
let attrs = attr::find_attrs_by_name(attrs, level_name);
|
||||
for attrs.each |attr| {
|
||||
let meta = attr.node.value;
|
||||
let metas = match meta.node {
|
||||
ast::meta_list(_, ref metas) => metas,
|
||||
_ => {
|
||||
sess.span_err(meta.span, ~"malformed lint attribute");
|
||||
loop;
|
||||
}
|
||||
};
|
||||
for metas.each |meta| {
|
||||
match meta.node {
|
||||
ast::meta_word(lintname) => {
|
||||
if !f(*meta, level, lintname) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
sess.span_err(meta.span, ~"malformed lint attribute");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
pub fn each_lint(sess: session::Session,
|
||||
attrs: &[ast::attribute],
|
||||
f: &fn(@ast::meta_item, level, &~str) -> bool) -> bool
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1367,21 +1367,6 @@ pub struct mono_id_ {
|
||||
|
||||
pub type mono_id = @mono_id_;
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for mono_param_id {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
match *self {
|
||||
mono_precise(t, ref mids) =>
|
||||
to_bytes::iter_bytes_3(&0u8, &ty::type_id(t), mids, lsb0, f),
|
||||
|
||||
mono_any => 1u8.iter_bytes(lsb0, f),
|
||||
|
||||
mono_repr(ref a, ref b, ref c, ref d) =>
|
||||
to_bytes::iter_bytes_5(&2u8, a, b, c, d, lsb0, f)
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for mono_param_id {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
match *self {
|
||||
@ -1396,26 +1381,12 @@ impl to_bytes::IterBytes for mono_param_id {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for MonoDataClass {
|
||||
fn iter_bytes(&self, lsb0: bool, f:to_bytes::Cb) {
|
||||
(*self as u8).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for MonoDataClass {
|
||||
fn iter_bytes(&self, lsb0: bool, f:to_bytes::Cb) -> bool {
|
||||
(*self as u8).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for mono_id_ {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
to_bytes::iter_bytes_2(&self.def, &self.params, lsb0, f);
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for mono_id_ {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
to_bytes::iter_bytes_2(&self.def, &self.params, lsb0, f)
|
||||
|
@ -154,13 +154,6 @@ pub impl DatumMode {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for DatumMode {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
(*self as uint).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for DatumMode {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
(*self as uint).iter_bytes(lsb0, f)
|
||||
|
@ -26,8 +26,6 @@ use util::ppaux::{Repr, UserString};
|
||||
use util::common::{indenter};
|
||||
use util::enum_set::{EnumSet, CLike};
|
||||
|
||||
#[cfg(stage0)]
|
||||
use core; // NOTE: this can be removed after the next snapshot
|
||||
use core::ptr::to_unsafe_ptr;
|
||||
use core::to_bytes;
|
||||
use core::hashmap::{HashMap, HashSet};
|
||||
@ -136,13 +134,6 @@ pub struct creader_cache_key {
|
||||
|
||||
type creader_cache = @mut HashMap<creader_cache_key, t>;
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for creader_cache_key {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
to_bytes::iter_bytes_3(&self.cnum, &self.pos, &self.len, lsb0, f);
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for creader_cache_key {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
to_bytes::iter_bytes_3(&self.cnum, &self.pos, &self.len, lsb0, f)
|
||||
@ -167,15 +158,6 @@ impl cmp::Eq for intern_key {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for intern_key {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
unsafe {
|
||||
(*self.sty).iter_bytes(lsb0, f);
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for intern_key {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
unsafe {
|
||||
@ -408,27 +390,12 @@ pub struct FnSig {
|
||||
output: t
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for BareFnTy {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
to_bytes::iter_bytes_3(&self.purity, &self.abis, &self.sig, lsb0, f)
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for BareFnTy {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
to_bytes::iter_bytes_3(&self.purity, &self.abis, &self.sig, lsb0, f)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for ClosureTy {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
to_bytes::iter_bytes_5(&self.purity, &self.sigil, &self.onceness,
|
||||
&self.region, &self.sig, lsb0, f)
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for ClosureTy {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
to_bytes::iter_bytes_5(&self.purity, &self.sigil, &self.onceness,
|
||||
@ -747,17 +714,6 @@ pub enum InferTy {
|
||||
FloatVar(FloatVid)
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for InferTy {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
match *self {
|
||||
TyVar(ref tv) => to_bytes::iter_bytes_2(&0u8, tv, lsb0, f),
|
||||
IntVar(ref iv) => to_bytes::iter_bytes_2(&1u8, iv, lsb0, f),
|
||||
FloatVar(ref fv) => to_bytes::iter_bytes_2(&2u8, fv, lsb0, f),
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for InferTy {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
match *self {
|
||||
@ -774,16 +730,6 @@ pub enum InferRegion {
|
||||
ReSkolemized(uint, bound_region)
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for InferRegion {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
match *self {
|
||||
ReVar(ref rv) => to_bytes::iter_bytes_2(&0u8, rv, lsb0, f),
|
||||
ReSkolemized(ref v, _) => to_bytes::iter_bytes_2(&1u8, v, lsb0, f)
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for InferRegion {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
match *self {
|
||||
@ -872,52 +818,24 @@ impl ToStr for IntVarValue {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for TyVid {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
self.to_uint().iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for TyVid {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
self.to_uint().iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for IntVid {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
self.to_uint().iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for IntVid {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
self.to_uint().iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for FloatVid {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
self.to_uint().iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for FloatVid {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
self.to_uint().iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for RegionVid {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
self.to_uint().iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for RegionVid {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
self.to_uint().iter_bytes(lsb0, f)
|
||||
@ -2718,22 +2636,6 @@ impl cmp::TotalEq for bound_region {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for vstore {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
match *self {
|
||||
vstore_fixed(ref u) =>
|
||||
to_bytes::iter_bytes_2(&0u8, u, lsb0, f),
|
||||
|
||||
vstore_uniq => 1u8.iter_bytes(lsb0, f),
|
||||
vstore_box => 2u8.iter_bytes(lsb0, f),
|
||||
|
||||
vstore_slice(ref r) =>
|
||||
to_bytes::iter_bytes_2(&3u8, r, lsb0, f),
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for vstore {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
match *self {
|
||||
@ -2749,15 +2651,6 @@ impl to_bytes::IterBytes for vstore {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for substs {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
to_bytes::iter_bytes_3(&self.self_r,
|
||||
&self.self_ty,
|
||||
&self.tps, lsb0, f)
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for substs {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
to_bytes::iter_bytes_3(&self.self_r,
|
||||
@ -2766,14 +2659,6 @@ impl to_bytes::IterBytes for substs {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for mt {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
to_bytes::iter_bytes_2(&self.ty,
|
||||
&self.mutbl, lsb0, f)
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for mt {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
to_bytes::iter_bytes_2(&self.ty,
|
||||
@ -2781,14 +2666,6 @@ impl to_bytes::IterBytes for mt {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for field {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
to_bytes::iter_bytes_2(&self.ident,
|
||||
&self.mt, lsb0, f)
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for field {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
to_bytes::iter_bytes_2(&self.ident,
|
||||
@ -2796,15 +2673,6 @@ impl to_bytes::IterBytes for field {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for FnSig {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
to_bytes::iter_bytes_2(&self.inputs,
|
||||
&self.output,
|
||||
lsb0, f);
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for FnSig {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
to_bytes::iter_bytes_2(&self.inputs,
|
||||
@ -2813,82 +2681,6 @@ impl to_bytes::IterBytes for FnSig {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for sty {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
match *self {
|
||||
ty_nil => 0u8.iter_bytes(lsb0, f),
|
||||
ty_bool => 1u8.iter_bytes(lsb0, f),
|
||||
|
||||
ty_int(ref t) =>
|
||||
to_bytes::iter_bytes_2(&2u8, t, lsb0, f),
|
||||
|
||||
ty_uint(ref t) =>
|
||||
to_bytes::iter_bytes_2(&3u8, t, lsb0, f),
|
||||
|
||||
ty_float(ref t) =>
|
||||
to_bytes::iter_bytes_2(&4u8, t, lsb0, f),
|
||||
|
||||
ty_estr(ref v) =>
|
||||
to_bytes::iter_bytes_2(&5u8, v, lsb0, f),
|
||||
|
||||
ty_enum(ref did, ref substs) =>
|
||||
to_bytes::iter_bytes_3(&6u8, did, substs, lsb0, f),
|
||||
|
||||
ty_box(ref mt) =>
|
||||
to_bytes::iter_bytes_2(&7u8, mt, lsb0, f),
|
||||
|
||||
ty_evec(ref mt, ref v) =>
|
||||
to_bytes::iter_bytes_3(&8u8, mt, v, lsb0, f),
|
||||
|
||||
ty_unboxed_vec(ref mt) =>
|
||||
to_bytes::iter_bytes_2(&9u8, mt, lsb0, f),
|
||||
|
||||
ty_tup(ref ts) =>
|
||||
to_bytes::iter_bytes_2(&10u8, ts, lsb0, f),
|
||||
|
||||
ty_bare_fn(ref ft) =>
|
||||
to_bytes::iter_bytes_2(&12u8, ft, lsb0, f),
|
||||
|
||||
ty_self(ref did) => to_bytes::iter_bytes_2(&13u8, did, lsb0, f),
|
||||
|
||||
ty_infer(ref v) =>
|
||||
to_bytes::iter_bytes_2(&14u8, v, lsb0, f),
|
||||
|
||||
ty_param(ref p) =>
|
||||
to_bytes::iter_bytes_2(&15u8, p, lsb0, f),
|
||||
|
||||
ty_type => 16u8.iter_bytes(lsb0, f),
|
||||
ty_bot => 17u8.iter_bytes(lsb0, f),
|
||||
|
||||
ty_ptr(ref mt) =>
|
||||
to_bytes::iter_bytes_2(&18u8, mt, lsb0, f),
|
||||
|
||||
ty_uniq(ref mt) =>
|
||||
to_bytes::iter_bytes_2(&19u8, mt, lsb0, f),
|
||||
|
||||
ty_trait(ref did, ref substs, ref v, ref mutbl) =>
|
||||
to_bytes::iter_bytes_5(&20u8, did, substs, v, mutbl, lsb0, f),
|
||||
|
||||
ty_opaque_closure_ptr(ref ck) =>
|
||||
to_bytes::iter_bytes_2(&21u8, ck, lsb0, f),
|
||||
|
||||
ty_opaque_box => 22u8.iter_bytes(lsb0, f),
|
||||
|
||||
ty_struct(ref did, ref substs) =>
|
||||
to_bytes::iter_bytes_3(&23u8, did, substs, lsb0, f),
|
||||
|
||||
ty_rptr(ref r, ref mt) =>
|
||||
to_bytes::iter_bytes_3(&24u8, r, mt, lsb0, f),
|
||||
|
||||
ty_err => 25u8.iter_bytes(lsb0, f),
|
||||
|
||||
ty_closure(ref ct) =>
|
||||
to_bytes::iter_bytes_2(&26u8, ct, lsb0, f),
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for sty {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
match *self {
|
||||
@ -4499,52 +4291,6 @@ pub fn determine_inherited_purity(parent: (ast::purity, ast::node_id),
|
||||
// Here, the supertraits are the transitive closure of the supertrait
|
||||
// relation on the supertraits from each bounded trait's constraint
|
||||
// list.
|
||||
#[cfg(stage0)]
|
||||
pub fn each_bound_trait_and_supertraits(tcx: ctxt,
|
||||
bounds: &ParamBounds,
|
||||
f: &fn(@TraitRef) -> bool) {
|
||||
for bounds.trait_bounds.each |&bound_trait_ref| {
|
||||
let mut supertrait_set = HashMap::new();
|
||||
let mut trait_refs = ~[];
|
||||
let mut i = 0;
|
||||
|
||||
// Seed the worklist with the trait from the bound
|
||||
supertrait_set.insert(bound_trait_ref.def_id, ());
|
||||
trait_refs.push(bound_trait_ref);
|
||||
|
||||
// Add the given trait ty to the hash map
|
||||
while i < trait_refs.len() {
|
||||
debug!("each_bound_trait_and_supertraits(i=%?, trait_ref=%s)",
|
||||
i, trait_refs[i].repr(tcx));
|
||||
|
||||
if !f(trait_refs[i]) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Add supertraits to supertrait_set
|
||||
let supertrait_refs = trait_ref_supertraits(tcx, trait_refs[i]);
|
||||
for supertrait_refs.each |&supertrait_ref| {
|
||||
debug!("each_bound_trait_and_supertraits(supertrait_ref=%s)",
|
||||
supertrait_ref.repr(tcx));
|
||||
|
||||
let d_id = supertrait_ref.def_id;
|
||||
if !supertrait_set.contains_key(&d_id) {
|
||||
// FIXME(#5527) Could have same trait multiple times
|
||||
supertrait_set.insert(d_id, ());
|
||||
trait_refs.push(supertrait_ref);
|
||||
}
|
||||
}
|
||||
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Iterate over a type parameter's bounded traits and any supertraits
|
||||
// of those traits, ignoring kinds.
|
||||
// Here, the supertraits are the transitive closure of the supertrait
|
||||
// relation on the supertraits from each bounded trait's constraint
|
||||
// list.
|
||||
#[cfg(not(stage0))]
|
||||
pub fn each_bound_trait_and_supertraits(tcx: ctxt,
|
||||
bounds: &ParamBounds,
|
||||
f: &fn(@TraitRef) -> bool) -> bool {
|
||||
|
@ -828,15 +828,6 @@ pub impl FnCtxt {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
fn opt_node_ty_substs(&self, id: ast::node_id,
|
||||
f: &fn(&ty::substs) -> bool) {
|
||||
match self.inh.node_type_substs.find(&id) {
|
||||
Some(s) => { f(s); }
|
||||
None => ()
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
fn opt_node_ty_substs(&self, id: ast::node_id,
|
||||
f: &fn(&ty::substs) -> bool) -> bool {
|
||||
match self.inh.node_type_substs.find(&id) {
|
||||
|
@ -118,26 +118,6 @@ pub impl Rcx {
|
||||
}
|
||||
|
||||
/// Try to resolve the type for the given node.
|
||||
#[config(stage0)]
|
||||
fn resolve_expr_type_adjusted(@mut self, expr: @ast::expr) -> ty::t {
|
||||
let ty_unadjusted = self.resolve_node_type(expr.id);
|
||||
if ty::type_is_error(ty_unadjusted) || ty::type_is_bot(ty_unadjusted) {
|
||||
ty_unadjusted
|
||||
} else {
|
||||
let tcx = self.fcx.tcx();
|
||||
let adjustments = self.fcx.inh.adjustments;
|
||||
match adjustments.find_copy(&expr.id) {
|
||||
None => ty_unadjusted,
|
||||
Some(adjustment) => {
|
||||
ty::adjust_ty(tcx, expr.span, ty_unadjusted,
|
||||
Some(adjustment))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Try to resolve the type for the given node.
|
||||
#[config(not(stage0))]
|
||||
fn resolve_expr_type_adjusted(@mut self, expr: @ast::expr) -> ty::t {
|
||||
let ty_unadjusted = self.resolve_node_type(expr.id);
|
||||
if ty::type_is_error(ty_unadjusted) || ty::type_is_bot(ty_unadjusted) {
|
||||
|
@ -524,27 +524,6 @@ pub impl CoherenceChecker {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
fn each_provided_trait_method(&self,
|
||||
trait_did: ast::def_id,
|
||||
f: &fn(@ty::Method) -> bool) {
|
||||
// Make a list of all the names of the provided methods.
|
||||
// XXX: This is horrible.
|
||||
let mut provided_method_idents = HashSet::new();
|
||||
let tcx = self.crate_context.tcx;
|
||||
for ty::provided_trait_methods(tcx, trait_did).each |ident| {
|
||||
provided_method_idents.insert(*ident);
|
||||
}
|
||||
|
||||
for ty::trait_methods(tcx, trait_did).each |&method| {
|
||||
if provided_method_idents.contains(&method.ident) {
|
||||
if !f(method) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
fn each_provided_trait_method(&self,
|
||||
trait_did: ast::def_id,
|
||||
f: &fn(x: @ty::Method) -> bool) -> bool {
|
||||
|
@ -544,8 +544,6 @@ use middle::typeck::infer::cres;
|
||||
use util::common::indenter;
|
||||
use util::ppaux::note_and_explain_region;
|
||||
|
||||
#[cfg(stage0)]
|
||||
use core; // NOTE: this can be removed after next snapshot
|
||||
use core::cell::{Cell, empty_cell};
|
||||
use core::hashmap::{HashMap, HashSet};
|
||||
use core::to_bytes;
|
||||
@ -561,22 +559,6 @@ enum Constraint {
|
||||
ConstrainVarSubReg(RegionVid, Region)
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for Constraint {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
match *self {
|
||||
ConstrainVarSubVar(ref v0, ref v1) =>
|
||||
to_bytes::iter_bytes_3(&0u8, v0, v1, lsb0, f),
|
||||
|
||||
ConstrainRegSubVar(ref ra, ref va) =>
|
||||
to_bytes::iter_bytes_3(&1u8, ra, va, lsb0, f),
|
||||
|
||||
ConstrainVarSubReg(ref va, ref ra) =>
|
||||
to_bytes::iter_bytes_3(&2u8, va, ra, lsb0, f)
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for Constraint {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
match *self {
|
||||
@ -1773,23 +1755,6 @@ pub impl RegionVarBindings {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
fn each_edge(&mut self,
|
||||
graph: &Graph,
|
||||
node_idx: RegionVid,
|
||||
dir: Direction,
|
||||
op: &fn(edge: &GraphEdge) -> bool) {
|
||||
let mut edge_idx =
|
||||
graph.nodes[node_idx.to_uint()].head_edge[dir as uint];
|
||||
while edge_idx != uint::max_value {
|
||||
let edge_ptr = &graph.edges[edge_idx];
|
||||
if !op(edge_ptr) {
|
||||
return;
|
||||
}
|
||||
edge_idx = edge_ptr.next_edge[dir as uint];
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
fn each_edge(&mut self,
|
||||
graph: &Graph,
|
||||
node_idx: RegionVid,
|
||||
|
@ -75,9 +75,6 @@ pub mod middle {
|
||||
}
|
||||
pub mod ty;
|
||||
pub mod subst;
|
||||
#[cfg(stage0)] #[path = "resolve_stage0.rs"]
|
||||
pub mod resolve;
|
||||
#[cfg(not(stage0))]
|
||||
pub mod resolve;
|
||||
#[path = "typeck/mod.rs"]
|
||||
pub mod typeck;
|
||||
|
@ -8,9 +8,6 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[cfg(stage0)]
|
||||
use core;
|
||||
|
||||
#[deriving(Eq, IterBytes)]
|
||||
pub struct EnumSet<E> {
|
||||
// We must maintain the invariant that no bits are set
|
||||
@ -60,22 +57,6 @@ pub impl<E:CLike> EnumSet<E> {
|
||||
(self.bits & bit(e)) != 0
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
fn each(&self, f: &fn(E) -> bool) {
|
||||
let mut bits = self.bits;
|
||||
let mut index = 0;
|
||||
while bits != 0 {
|
||||
if (bits & 1) != 0 {
|
||||
let e = CLike::from_uint(index);
|
||||
if !f(e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
index += 1;
|
||||
bits >>= 1;
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
fn each(&self, f: &fn(E) -> bool) -> bool {
|
||||
let mut bits = self.bits;
|
||||
let mut index = 0;
|
||||
|
@ -143,17 +143,6 @@ pub impl BigBitv {
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[cfg(stage0)]
|
||||
fn each_storage(&mut self, op: &fn(v: &mut uint) -> bool) {
|
||||
for uint::range(0, self.storage.len()) |i| {
|
||||
let mut w = self.storage[i];
|
||||
let b = op(&mut w);
|
||||
self.storage[i] = w;
|
||||
if !b { break; }
|
||||
}
|
||||
}
|
||||
#[inline(always)]
|
||||
#[cfg(not(stage0))]
|
||||
fn each_storage(&mut self, op: &fn(v: &mut uint) -> bool) -> bool {
|
||||
uint::range(0, self.storage.len(), |i| op(&mut self.storage[i]))
|
||||
}
|
||||
@ -199,19 +188,6 @@ pub impl BigBitv {
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[cfg(stage0)]
|
||||
fn equals(&self, b: &BigBitv, nbits: uint) -> bool {
|
||||
let len = b.storage.len();
|
||||
for uint::iterate(0, len) |i| {
|
||||
let mask = big_mask(nbits, i);
|
||||
if mask & self.storage[i] != mask & b.storage[i] {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[cfg(not(stage0))]
|
||||
fn equals(&self, b: &BigBitv, nbits: uint) -> bool {
|
||||
let len = b.storage.len();
|
||||
for uint::iterate(0, len) |i| {
|
||||
@ -407,16 +383,6 @@ pub impl Bitv {
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[cfg(stage0)]
|
||||
fn each(&self, f: &fn(bool) -> bool) {
|
||||
let mut i = 0;
|
||||
while i < self.nbits {
|
||||
if !f(self.get(i)) { break; }
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
#[inline(always)]
|
||||
#[cfg(not(stage0))]
|
||||
fn each(&self, f: &fn(bool) -> bool) -> bool {
|
||||
let mut i = 0;
|
||||
while i < self.nbits {
|
||||
@ -519,15 +485,6 @@ pub impl Bitv {
|
||||
true
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
fn ones(&self, f: &fn(uint) -> bool) {
|
||||
for uint::range(0, self.nbits) |i| {
|
||||
if self.get(i) {
|
||||
if !f(i) { break }
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
fn ones(&self, f: &fn(uint) -> bool) -> bool {
|
||||
uint::range(0, self.nbits, |i| !self.get(i) || f(i))
|
||||
}
|
||||
@ -697,7 +654,6 @@ pub impl BitvSet {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
impl BaseIter<uint> for BitvSet {
|
||||
fn size_hint(&self) -> Option<uint> { Some(self.len()) }
|
||||
|
||||
@ -711,7 +667,6 @@ impl BaseIter<uint> for BitvSet {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
impl cmp::Eq for BitvSet {
|
||||
fn eq(&self, other: &BitvSet) -> bool {
|
||||
if self.size != other.size {
|
||||
@ -745,7 +700,6 @@ impl Mutable for BitvSet {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
impl Set<uint> for BitvSet {
|
||||
fn contains(&self, value: &uint) -> bool {
|
||||
*value < self.bitv.storage.len() * uint::bits && self.bitv.get(*value)
|
||||
@ -849,7 +803,6 @@ impl Set<uint> for BitvSet {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
priv impl BitvSet {
|
||||
/// Visits each of the words that the two bit vectors (self and other)
|
||||
/// both have in common. The three yielded arguments are (bit location,
|
||||
|
@ -65,23 +65,11 @@ pub impl<T> Deque<T> {
|
||||
}
|
||||
|
||||
/// Iterate over the elements in the deque
|
||||
#[cfg(stage0)]
|
||||
fn each(&self, f: &fn(&T) -> bool) {
|
||||
self.eachi(|_i, e| f(e))
|
||||
}
|
||||
/// Iterate over the elements in the deque
|
||||
#[cfg(not(stage0))]
|
||||
fn each(&self, f: &fn(&T) -> bool) -> bool {
|
||||
self.eachi(|_i, e| f(e))
|
||||
}
|
||||
|
||||
/// Iterate over the elements in the deque by index
|
||||
#[cfg(stage0)]
|
||||
fn eachi(&self, f: &fn(uint, &T) -> bool) {
|
||||
uint::range(0, self.nelts, |i| f(i, self.get(i as int)))
|
||||
}
|
||||
/// Iterate over the elements in the deque by index
|
||||
#[cfg(not(stage0))]
|
||||
fn eachi(&self, f: &fn(uint, &T) -> bool) -> bool {
|
||||
uint::range(0, self.nelts, |i| f(i, self.get(i as int)))
|
||||
}
|
||||
|
@ -391,17 +391,6 @@ pub impl<T> DList<T> {
|
||||
}
|
||||
|
||||
/// Iterate over nodes.
|
||||
#[cfg(stage0)]
|
||||
fn each_node(@mut self, f: &fn(@mut DListNode<T>) -> bool) {
|
||||
let mut link = self.peek_n();
|
||||
while link.is_some() {
|
||||
let nobe = link.get();
|
||||
if !f(nobe) { break; }
|
||||
link = nobe.next_link();
|
||||
}
|
||||
}
|
||||
/// Iterate over nodes.
|
||||
#[cfg(not(stage0))]
|
||||
fn each_node(@mut self, f: &fn(@mut DListNode<T>) -> bool) -> bool {
|
||||
let mut link = self.peek_n();
|
||||
while link.is_some() {
|
||||
@ -508,42 +497,6 @@ impl<T> BaseIter<T> for @mut DList<T> {
|
||||
* allow for e.g. breadth-first search with in-place enqueues), but
|
||||
* removing the current node is forbidden.
|
||||
*/
|
||||
#[cfg(stage0)]
|
||||
fn each(&self, f: &fn(v: &T) -> bool) {
|
||||
let mut link = self.peek_n();
|
||||
while link.is_some() {
|
||||
let nobe = link.get();
|
||||
assert!(nobe.linked);
|
||||
|
||||
{
|
||||
let frozen_nobe = &*nobe;
|
||||
if !f(&frozen_nobe.data) { break; }
|
||||
}
|
||||
|
||||
// Check (weakly) that the user didn't do a remove.
|
||||
if self.size == 0 {
|
||||
fail!("The dlist became empty during iteration??")
|
||||
}
|
||||
if !nobe.linked ||
|
||||
(!((nobe.prev.is_some()
|
||||
|| managed::mut_ptr_eq(self.hd.expect(~"headless dlist?"),
|
||||
nobe))
|
||||
&& (nobe.next.is_some()
|
||||
|| managed::mut_ptr_eq(self.tl.expect(~"tailless dlist?"),
|
||||
nobe)))) {
|
||||
fail!("Removing a dlist node during iteration is forbidden!")
|
||||
}
|
||||
link = nobe.next_link();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Iterates through the current contents.
|
||||
*
|
||||
* Attempts to access this dlist during iteration are allowed (to
|
||||
* allow for e.g. breadth-first search with in-place enqueues), but
|
||||
* removing the current node is forbidden.
|
||||
*/
|
||||
#[cfg(not(stage0))]
|
||||
fn each(&self, f: &fn(v: &T) -> bool) -> bool {
|
||||
let mut link = self.peek_n();
|
||||
while link.is_some() {
|
||||
|
@ -200,20 +200,6 @@ pub mod reader {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub fn docs(d: Doc, it: &fn(uint, Doc) -> bool) {
|
||||
let mut pos = d.start;
|
||||
while pos < d.end {
|
||||
let elt_tag = vuint_at(*d.data, pos);
|
||||
let elt_size = vuint_at(*d.data, elt_tag.next);
|
||||
pos = elt_size.next + elt_size.val;
|
||||
let doc = Doc { data: d.data, start: elt_size.next, end: pos };
|
||||
if !it(elt_tag.val, doc) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
pub fn docs(d: Doc, it: &fn(uint, Doc) -> bool) -> bool {
|
||||
let mut pos = d.start;
|
||||
while pos < d.end {
|
||||
@ -228,23 +214,6 @@ pub mod reader {
|
||||
return true;
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub fn tagged_docs(d: Doc, tg: uint, it: &fn(Doc) -> bool) {
|
||||
let mut pos = d.start;
|
||||
while pos < d.end {
|
||||
let elt_tag = vuint_at(*d.data, pos);
|
||||
let elt_size = vuint_at(*d.data, elt_tag.next);
|
||||
pos = elt_size.next + elt_size.val;
|
||||
if elt_tag.val == tg {
|
||||
let doc = Doc { data: d.data, start: elt_size.next,
|
||||
end: pos };
|
||||
if !it(doc) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
pub fn tagged_docs(d: Doc, tg: uint, it: &fn(Doc) -> bool) -> bool {
|
||||
let mut pos = d.start;
|
||||
while pos < d.end {
|
||||
@ -655,16 +624,6 @@ pub mod writer {
|
||||
fail!("vint to write too big: %?", n);
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub fn Encoder(w: @io::Writer) -> Encoder {
|
||||
let size_positions: ~[uint] = ~[];
|
||||
Encoder {
|
||||
writer: w,
|
||||
mut size_positions: size_positions
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
pub fn Encoder(w: @io::Writer) -> Encoder {
|
||||
let size_positions: ~[uint] = ~[];
|
||||
Encoder {
|
||||
|
@ -254,17 +254,6 @@ impl FileInput {
|
||||
(line numbers and file names, see documentation for
|
||||
`FileInputState`). Otherwise identical to `lines_each`.
|
||||
*/
|
||||
#[cfg(stage0)]
|
||||
pub fn each_line_state(&self,
|
||||
f: &fn(&str, FileInputState) -> bool) {
|
||||
self.each_line(|line| f(line, copy self.fi.state));
|
||||
}
|
||||
/**
|
||||
Apply `f` to each line successively, along with some state
|
||||
(line numbers and file names, see documentation for
|
||||
`FileInputState`). Otherwise identical to `lines_each`.
|
||||
*/
|
||||
#[cfg(not(stage0))]
|
||||
pub fn each_line_state(&self,
|
||||
f: &fn(&str, FileInputState) -> bool) -> bool {
|
||||
self.each_line(|line| f(line, copy self.fi.state))
|
||||
@ -377,17 +366,6 @@ reading from `stdin`).
|
||||
|
||||
Fails when attempting to read from a file that can't be opened.
|
||||
*/
|
||||
#[cfg(stage0)]
|
||||
pub fn input(f: &fn(&str) -> bool) {
|
||||
FileInput::from_args().each_line(f);
|
||||
}
|
||||
/**
|
||||
Iterate directly over the command line arguments (no arguments implies
|
||||
reading from `stdin`).
|
||||
|
||||
Fails when attempting to read from a file that can't be opened.
|
||||
*/
|
||||
#[cfg(not(stage0))]
|
||||
pub fn input(f: &fn(&str) -> bool) -> bool {
|
||||
let i = FileInput::from_args();
|
||||
i.each_line(f)
|
||||
@ -400,18 +378,6 @@ provided at each call.
|
||||
|
||||
Fails when attempting to read from a file that can't be opened.
|
||||
*/
|
||||
#[cfg(stage0)]
|
||||
pub fn input_state(f: &fn(&str, FileInputState) -> bool) {
|
||||
FileInput::from_args().each_line_state(f);
|
||||
}
|
||||
/**
|
||||
Iterate directly over the command line arguments (no arguments
|
||||
implies reading from `stdin`) with the current state of the iteration
|
||||
provided at each call.
|
||||
|
||||
Fails when attempting to read from a file that can't be opened.
|
||||
*/
|
||||
#[cfg(not(stage0))]
|
||||
pub fn input_state(f: &fn(&str, FileInputState) -> bool) -> bool {
|
||||
let i = FileInput::from_args();
|
||||
i.each_line_state(f)
|
||||
@ -422,16 +388,6 @@ Iterate over a vector of files (an empty vector implies just `stdin`).
|
||||
|
||||
Fails when attempting to read from a file that can't be opened.
|
||||
*/
|
||||
#[cfg(stage0)]
|
||||
pub fn input_vec(files: ~[Option<Path>], f: &fn(&str) -> bool) {
|
||||
FileInput::from_vec(files).each_line(f);
|
||||
}
|
||||
/**
|
||||
Iterate over a vector of files (an empty vector implies just `stdin`).
|
||||
|
||||
Fails when attempting to read from a file that can't be opened.
|
||||
*/
|
||||
#[cfg(not(stage0))]
|
||||
pub fn input_vec(files: ~[Option<Path>], f: &fn(&str) -> bool) -> bool {
|
||||
let i = FileInput::from_vec(files);
|
||||
i.each_line(f)
|
||||
@ -443,18 +399,6 @@ with the current state of the iteration provided at each call.
|
||||
|
||||
Fails when attempting to read from a file that can't be opened.
|
||||
*/
|
||||
#[cfg(stage0)]
|
||||
pub fn input_vec_state(files: ~[Option<Path>],
|
||||
f: &fn(&str, FileInputState) -> bool) {
|
||||
FileInput::from_vec(files).each_line_state(f);
|
||||
}
|
||||
/**
|
||||
Iterate over a vector of files (an empty vector implies just `stdin`)
|
||||
with the current state of the iteration provided at each call.
|
||||
|
||||
Fails when attempting to read from a file that can't be opened.
|
||||
*/
|
||||
#[cfg(not(stage0))]
|
||||
pub fn input_vec_state(files: ~[Option<Path>],
|
||||
f: &fn(&str, FileInputState) -> bool) -> bool {
|
||||
let i = FileInput::from_vec(files);
|
||||
|
@ -140,21 +140,6 @@ pub fn iter<T>(l: @List<T>, f: &fn(&T)) {
|
||||
}
|
||||
|
||||
/// Iterate over a list
|
||||
#[cfg(stage0)]
|
||||
pub fn each<T>(l: @List<T>, f: &fn(&T) -> bool) {
|
||||
let mut cur = l;
|
||||
loop {
|
||||
cur = match *cur {
|
||||
Cons(ref hd, tl) => {
|
||||
if !f(hd) { return; }
|
||||
tl
|
||||
}
|
||||
Nil => break
|
||||
}
|
||||
}
|
||||
}
|
||||
/// Iterate over a list
|
||||
#[cfg(not(stage0))]
|
||||
pub fn each<T>(l: @List<T>, f: &fn(&T) -> bool) -> bool {
|
||||
let mut cur = l;
|
||||
loop {
|
||||
@ -170,24 +155,6 @@ pub fn each<T>(l: @List<T>, f: &fn(&T) -> bool) -> bool {
|
||||
|
||||
impl<T> MutList<T> {
|
||||
/// Iterate over a mutable list
|
||||
#[cfg(stage0)]
|
||||
pub fn each(@mut self, f: &fn(&mut T) -> bool) {
|
||||
let mut cur = self;
|
||||
loop {
|
||||
let borrowed = &mut *cur;
|
||||
cur = match *borrowed {
|
||||
MutCons(ref mut hd, tl) => {
|
||||
if !f(hd) {
|
||||
return;
|
||||
}
|
||||
tl
|
||||
}
|
||||
MutNil => break
|
||||
}
|
||||
}
|
||||
}
|
||||
/// Iterate over a mutable list
|
||||
#[cfg(not(stage0))]
|
||||
pub fn each(@mut self, f: &fn(&mut T) -> bool) -> bool {
|
||||
let mut cur = self;
|
||||
loop {
|
||||
|
@ -703,13 +703,6 @@ impl ToStr for Url {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl IterBytes for Url {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
self.to_str().iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl IterBytes for Url {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
self.to_str().iter_bytes(lsb0, f)
|
||||
|
@ -22,12 +22,6 @@ impl<T:Ord> BaseIter<T> for PriorityQueue<T> {
|
||||
/// Visit all values in the underlying vector.
|
||||
///
|
||||
/// The values are **not** visited in order.
|
||||
#[cfg(stage0)]
|
||||
fn each(&self, f: &fn(&T) -> bool) { self.data.each(f) }
|
||||
/// Visit all values in the underlying vector.
|
||||
///
|
||||
/// The values are **not** visited in order.
|
||||
#[cfg(not(stage0))]
|
||||
fn each(&self, f: &fn(&T) -> bool) -> bool { self.data.each(f) }
|
||||
|
||||
fn size_hint(&self) -> Option<uint> { self.data.size_hint() }
|
||||
|
@ -61,7 +61,6 @@ pub impl<T> Rc<T> {
|
||||
}
|
||||
|
||||
#[unsafe_destructor]
|
||||
#[cfg(not(stage0))]
|
||||
impl<T> Drop for Rc<T> {
|
||||
fn finalize(&self) {
|
||||
unsafe {
|
||||
@ -74,21 +73,6 @@ impl<T> Drop for Rc<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[unsafe_destructor]
|
||||
#[cfg(stage0)]
|
||||
impl<T> Drop for Rc<T> {
|
||||
fn finalize(&self) {
|
||||
unsafe {
|
||||
(*self.ptr).count -= 1;
|
||||
if (*self.ptr).count == 0 {
|
||||
util::replace_ptr(self.ptr, intrinsics::init());
|
||||
free(self.ptr as *c_void)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl<T> Clone for Rc<T> {
|
||||
/// Return a shallow copy of the reference counted pointer.
|
||||
#[inline]
|
||||
@ -157,7 +141,6 @@ mod test_rc {
|
||||
#[abi = "rust-intrinsic"]
|
||||
extern "rust-intrinsic" {
|
||||
fn init<T>() -> T;
|
||||
#[cfg(not(stage0))]
|
||||
fn uninit<T>() -> T;
|
||||
}
|
||||
|
||||
@ -228,7 +211,6 @@ pub impl<T> RcMut<T> {
|
||||
}
|
||||
|
||||
#[unsafe_destructor]
|
||||
#[cfg(not(stage0))]
|
||||
impl<T> Drop for RcMut<T> {
|
||||
fn finalize(&self) {
|
||||
unsafe {
|
||||
@ -241,20 +223,6 @@ impl<T> Drop for RcMut<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[unsafe_destructor]
|
||||
#[cfg(stage0)]
|
||||
impl<T> Drop for RcMut<T> {
|
||||
fn finalize(&self) {
|
||||
unsafe {
|
||||
(*self.ptr).count -= 1;
|
||||
if (*self.ptr).count == 0 {
|
||||
util::replace_ptr(self.ptr, init());
|
||||
free(self.ptr as *c_void)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Clone for RcMut<T> {
|
||||
/// Return a shallow copy of the reference counted pointer.
|
||||
#[inline]
|
||||
|
@ -51,18 +51,6 @@ impl<V> Map<uint, V> for SmallIntMap<V> {
|
||||
}
|
||||
|
||||
/// Visit all key-value pairs in order
|
||||
#[cfg(stage0)]
|
||||
fn each<'a>(&'a self, it: &fn(&uint, &'a V) -> bool) {
|
||||
for uint::range(0, self.v.len()) |i| {
|
||||
match self.v[i] {
|
||||
Some(ref elt) => if !it(&i, elt) { break },
|
||||
None => ()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Visit all key-value pairs in order
|
||||
#[cfg(not(stage0))]
|
||||
fn each<'a>(&'a self, it: &fn(&uint, &'a V) -> bool) -> bool {
|
||||
for uint::range(0, self.v.len()) |i| {
|
||||
match self.v[i] {
|
||||
@ -73,41 +61,17 @@ impl<V> Map<uint, V> for SmallIntMap<V> {
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Visit all keys in order
|
||||
#[cfg(stage0)]
|
||||
fn each_key(&self, blk: &fn(key: &uint) -> bool) {
|
||||
self.each(|k, _| blk(k))
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
/// Visit all keys in order
|
||||
fn each_key(&self, blk: &fn(key: &uint) -> bool) -> bool {
|
||||
self.each(|k, _| blk(k))
|
||||
}
|
||||
|
||||
/// Visit all values in order
|
||||
#[cfg(stage0)]
|
||||
fn each_value<'a>(&'a self, blk: &fn(value: &'a V) -> bool) {
|
||||
self.each(|_, v| blk(v))
|
||||
}
|
||||
|
||||
/// Visit all values in order
|
||||
#[cfg(not(stage0))]
|
||||
fn each_value<'a>(&'a self, blk: &fn(value: &'a V) -> bool) -> bool {
|
||||
self.each(|_, v| blk(v))
|
||||
}
|
||||
|
||||
/// Iterate over the map and mutate the contained values
|
||||
#[cfg(stage0)]
|
||||
fn mutate_values(&mut self, it: &fn(&uint, &mut V) -> bool) {
|
||||
for uint::range(0, self.v.len()) |i| {
|
||||
match self.v[i] {
|
||||
Some(ref mut elt) => if !it(&i, elt) { return; },
|
||||
None => ()
|
||||
}
|
||||
}
|
||||
}
|
||||
/// Iterate over the map and mutate the contained values
|
||||
#[cfg(not(stage0))]
|
||||
fn mutate_values(&mut self, it: &fn(&uint, &mut V) -> bool) -> bool {
|
||||
for uint::range(0, self.v.len()) |i| {
|
||||
match self.v[i] {
|
||||
@ -187,18 +151,6 @@ pub impl<V> SmallIntMap<V> {
|
||||
fn new() -> SmallIntMap<V> { SmallIntMap{v: ~[]} }
|
||||
|
||||
/// Visit all key-value pairs in reverse order
|
||||
#[cfg(stage0)]
|
||||
fn each_reverse<'a>(&'a self, it: &fn(uint, &'a V) -> bool) {
|
||||
for uint::range_rev(self.v.len(), 0) |i| {
|
||||
match self.v[i - 1] {
|
||||
Some(ref elt) => if !it(i - 1, elt) { break },
|
||||
None => ()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Visit all key-value pairs in reverse order
|
||||
#[cfg(not(stage0))]
|
||||
fn each_reverse<'a>(&'a self, it: &fn(uint, &'a V) -> bool) -> bool {
|
||||
for uint::range_rev(self.v.len(), 0) |i| {
|
||||
match self.v[i - 1] {
|
||||
|
@ -61,26 +61,6 @@ pub fn merge_sort<T:Copy>(v: &[T], le: Le<T>) -> ~[T] {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
fn part<T>(arr: &mut [T], left: uint,
|
||||
right: uint, pivot: uint, compare_func: Le<T>) -> uint {
|
||||
swap(&mut arr[pivot], &mut arr[right]);
|
||||
let mut storage_index: uint = left;
|
||||
let mut i: uint = left;
|
||||
while i < right {
|
||||
let a: &mut T = &mut arr[i];
|
||||
let b: &mut T = &mut arr[right];
|
||||
if compare_func(a, b) {
|
||||
swap(&mut arr[i], &mut arr[storage_index]);
|
||||
storage_index += 1;
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
swap(&mut arr[storage_index], &mut arr[right]);
|
||||
return storage_index;
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
fn part<T>(arr: &mut [T], left: uint,
|
||||
right: uint, pivot: uint, compare_func: Le<T>) -> uint {
|
||||
vec::swap(arr, pivot, right);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -63,18 +63,12 @@ pub mod flatpipes;
|
||||
|
||||
pub mod bitv;
|
||||
pub mod deque;
|
||||
#[cfg(not(stage0))]
|
||||
pub mod fun_treemap;
|
||||
pub mod list;
|
||||
pub mod priority_queue;
|
||||
pub mod rope;
|
||||
pub mod smallintmap;
|
||||
|
||||
#[cfg(stage0)]
|
||||
#[path="sort_stage0.rs"]
|
||||
pub mod sort;
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
pub mod sort;
|
||||
|
||||
pub mod dlist;
|
||||
|
@ -105,45 +105,21 @@ impl<K: TotalOrd, V> Map<K, V> for TreeMap<K, V> {
|
||||
}
|
||||
|
||||
/// Visit all key-value pairs in order
|
||||
#[cfg(stage0)]
|
||||
fn each<'a>(&'a self, f: &fn(&'a K, &'a V) -> bool) {
|
||||
each(&self.root, f);
|
||||
}
|
||||
/// Visit all key-value pairs in order
|
||||
#[cfg(not(stage0))]
|
||||
fn each<'a>(&'a self, f: &fn(&'a K, &'a V) -> bool) -> bool {
|
||||
each(&self.root, f)
|
||||
}
|
||||
|
||||
/// Visit all keys in order
|
||||
#[cfg(stage0)]
|
||||
fn each_key(&self, f: &fn(&K) -> bool) {
|
||||
self.each(|k, _| f(k))
|
||||
}
|
||||
/// Visit all keys in order
|
||||
#[cfg(not(stage0))]
|
||||
fn each_key(&self, f: &fn(&K) -> bool) -> bool {
|
||||
self.each(|k, _| f(k))
|
||||
}
|
||||
|
||||
/// Visit all values in order
|
||||
#[cfg(stage0)]
|
||||
fn each_value<'a>(&'a self, f: &fn(&'a V) -> bool) {
|
||||
self.each(|_, v| f(v))
|
||||
}
|
||||
/// Visit all values in order
|
||||
#[cfg(not(stage0))]
|
||||
fn each_value<'a>(&'a self, f: &fn(&'a V) -> bool) -> bool {
|
||||
self.each(|_, v| f(v))
|
||||
}
|
||||
|
||||
/// Iterate over the map and mutate the contained values
|
||||
#[cfg(stage0)]
|
||||
fn mutate_values(&mut self, f: &fn(&K, &mut V) -> bool) {
|
||||
mutate_values(&mut self.root, f);
|
||||
}
|
||||
/// Iterate over the map and mutate the contained values
|
||||
#[cfg(not(stage0))]
|
||||
fn mutate_values(&mut self, f: &fn(&K, &mut V) -> bool) -> bool {
|
||||
mutate_values(&mut self.root, f)
|
||||
}
|
||||
@ -201,33 +177,6 @@ impl<K: TotalOrd, V> Map<K, V> for TreeMap<K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub impl<K: TotalOrd, V> TreeMap<K, V> {
|
||||
/// Create an empty TreeMap
|
||||
fn new() -> TreeMap<K, V> { TreeMap{root: None, length: 0} }
|
||||
|
||||
/// Visit all key-value pairs in reverse order
|
||||
fn each_reverse<'a>(&'a self, f: &fn(&'a K, &'a V) -> bool) {
|
||||
each_reverse(&self.root, f);
|
||||
}
|
||||
|
||||
/// Visit all keys in reverse order
|
||||
fn each_key_reverse(&self, f: &fn(&K) -> bool) {
|
||||
self.each_reverse(|k, _| f(k))
|
||||
}
|
||||
|
||||
/// Visit all values in reverse order
|
||||
fn each_value_reverse(&self, f: &fn(&V) -> bool) {
|
||||
self.each_reverse(|_, v| f(v))
|
||||
}
|
||||
|
||||
/// Get a lazy iterator over the key-value pairs in the map.
|
||||
/// Requires that it be frozen (immutable).
|
||||
fn iter<'a>(&'a self) -> TreeMapIterator<'a, K, V> {
|
||||
TreeMapIterator{stack: ~[], node: &self.root}
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
pub impl<K: TotalOrd, V> TreeMap<K, V> {
|
||||
/// Create an empty TreeMap
|
||||
fn new() -> TreeMap<K, V> { TreeMap{root: None, length: 0} }
|
||||
@ -297,11 +246,6 @@ pub struct TreeSet<T> {
|
||||
impl<T: TotalOrd> BaseIter<T> for TreeSet<T> {
|
||||
/// Visit all values in order
|
||||
#[inline(always)]
|
||||
#[cfg(stage0)]
|
||||
fn each(&self, f: &fn(&T) -> bool) { self.map.each_key(f) }
|
||||
/// Visit all values in order
|
||||
#[inline(always)]
|
||||
#[cfg(not(stage0))]
|
||||
fn each(&self, f: &fn(&T) -> bool) -> bool { self.map.each_key(f) }
|
||||
#[inline(always)]
|
||||
fn size_hint(&self) -> Option<uint> { Some(self.len()) }
|
||||
@ -309,13 +253,6 @@ impl<T: TotalOrd> BaseIter<T> for TreeSet<T> {
|
||||
|
||||
impl<T: TotalOrd> ReverseIter<T> for TreeSet<T> {
|
||||
/// Visit all values in reverse order
|
||||
#[cfg(stage0)]
|
||||
#[inline(always)]
|
||||
fn each_reverse(&self, f: &fn(&T) -> bool) {
|
||||
self.map.each_key_reverse(f)
|
||||
}
|
||||
/// Visit all values in reverse order
|
||||
#[cfg(not(stage0))]
|
||||
#[inline(always)]
|
||||
fn each_reverse(&self, f: &fn(&T) -> bool) -> bool {
|
||||
self.map.each_key_reverse(f)
|
||||
@ -424,37 +361,6 @@ impl<T: TotalOrd> Set<T> for TreeSet<T> {
|
||||
}
|
||||
|
||||
/// Visit the values (in-order) representing the difference
|
||||
#[cfg(stage0)]
|
||||
fn difference(&self, other: &TreeSet<T>, f: &fn(&T) -> bool) {
|
||||
let mut x = self.iter();
|
||||
let mut y = other.iter();
|
||||
|
||||
let mut a = x.next();
|
||||
let mut b = y.next();
|
||||
|
||||
while a.is_some() {
|
||||
if b.is_none() {
|
||||
return do a.while_some() |a1| {
|
||||
if f(a1) { x.next() } else { None }
|
||||
}
|
||||
}
|
||||
|
||||
let a1 = a.unwrap();
|
||||
let b1 = b.unwrap();
|
||||
|
||||
let cmp = a1.cmp(b1);
|
||||
|
||||
if cmp == Less {
|
||||
if !f(a1) { return }
|
||||
a = x.next();
|
||||
} else {
|
||||
if cmp == Equal { a = x.next() }
|
||||
b = y.next();
|
||||
}
|
||||
}
|
||||
}
|
||||
/// Visit the values (in-order) representing the difference
|
||||
#[cfg(not(stage0))]
|
||||
fn difference(&self, other: &TreeSet<T>, f: &fn(&T) -> bool) -> bool {
|
||||
let mut x = self.iter();
|
||||
let mut y = other.iter();
|
||||
@ -484,45 +390,6 @@ impl<T: TotalOrd> Set<T> for TreeSet<T> {
|
||||
}
|
||||
|
||||
/// Visit the values (in-order) representing the symmetric difference
|
||||
#[cfg(stage0)]
|
||||
fn symmetric_difference(&self, other: &TreeSet<T>,
|
||||
f: &fn(&T) -> bool) {
|
||||
let mut x = self.iter();
|
||||
let mut y = other.iter();
|
||||
|
||||
let mut a = x.next();
|
||||
let mut b = y.next();
|
||||
|
||||
while a.is_some() {
|
||||
if b.is_none() {
|
||||
return do a.while_some() |a1| {
|
||||
if f(a1) { x.next() } else { None }
|
||||
}
|
||||
}
|
||||
|
||||
let a1 = a.unwrap();
|
||||
let b1 = b.unwrap();
|
||||
|
||||
let cmp = a1.cmp(b1);
|
||||
|
||||
if cmp == Less {
|
||||
if !f(a1) { return }
|
||||
a = x.next();
|
||||
} else {
|
||||
if cmp == Greater {
|
||||
if !f(b1) { return }
|
||||
} else {
|
||||
a = x.next();
|
||||
}
|
||||
b = y.next();
|
||||
}
|
||||
}
|
||||
do b.while_some |b1| {
|
||||
if f(b1) { y.next() } else { None }
|
||||
}
|
||||
}
|
||||
/// Visit the values (in-order) representing the symmetric difference
|
||||
#[cfg(not(stage0))]
|
||||
fn symmetric_difference(&self, other: &TreeSet<T>,
|
||||
f: &fn(&T) -> bool) -> bool {
|
||||
let mut x = self.iter();
|
||||
@ -557,32 +424,6 @@ impl<T: TotalOrd> Set<T> for TreeSet<T> {
|
||||
}
|
||||
|
||||
/// Visit the values (in-order) representing the intersection
|
||||
#[cfg(stage0)]
|
||||
fn intersection(&self, other: &TreeSet<T>, f: &fn(&T) -> bool) {
|
||||
let mut x = self.iter();
|
||||
let mut y = other.iter();
|
||||
|
||||
let mut a = x.next();
|
||||
let mut b = y.next();
|
||||
|
||||
while a.is_some() && b.is_some() {
|
||||
let a1 = a.unwrap();
|
||||
let b1 = b.unwrap();
|
||||
|
||||
let cmp = a1.cmp(b1);
|
||||
|
||||
if cmp == Less {
|
||||
a = x.next();
|
||||
} else {
|
||||
if cmp == Equal {
|
||||
if !f(a1) { return }
|
||||
}
|
||||
b = y.next();
|
||||
}
|
||||
}
|
||||
}
|
||||
/// Visit the values (in-order) representing the intersection
|
||||
#[cfg(not(stage0))]
|
||||
fn intersection(&self, other: &TreeSet<T>, f: &fn(&T) -> bool) -> bool {
|
||||
let mut x = self.iter();
|
||||
let mut y = other.iter();
|
||||
@ -609,43 +450,6 @@ impl<T: TotalOrd> Set<T> for TreeSet<T> {
|
||||
}
|
||||
|
||||
/// Visit the values (in-order) representing the union
|
||||
#[cfg(stage0)]
|
||||
fn union(&self, other: &TreeSet<T>, f: &fn(&T) -> bool) {
|
||||
let mut x = self.iter();
|
||||
let mut y = other.iter();
|
||||
|
||||
let mut a = x.next();
|
||||
let mut b = y.next();
|
||||
|
||||
while a.is_some() {
|
||||
if b.is_none() {
|
||||
return do a.while_some() |a1| {
|
||||
if f(a1) { x.next() } else { None }
|
||||
}
|
||||
}
|
||||
|
||||
let a1 = a.unwrap();
|
||||
let b1 = b.unwrap();
|
||||
|
||||
let cmp = a1.cmp(b1);
|
||||
|
||||
if cmp == Greater {
|
||||
if !f(b1) { return }
|
||||
b = y.next();
|
||||
} else {
|
||||
if !f(a1) { return }
|
||||
if cmp == Equal {
|
||||
b = y.next();
|
||||
}
|
||||
a = x.next();
|
||||
}
|
||||
}
|
||||
do b.while_some |b1| {
|
||||
if f(b1) { y.next() } else { None }
|
||||
}
|
||||
}
|
||||
/// Visit the values (in-order) representing the union
|
||||
#[cfg(not(stage0))]
|
||||
fn union(&self, other: &TreeSet<T>, f: &fn(&T) -> bool) -> bool {
|
||||
let mut x = self.iter();
|
||||
let mut y = other.iter();
|
||||
@ -713,24 +517,12 @@ pub impl<K: TotalOrd, V> TreeNode<K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
fn each<'r, K: TotalOrd, V>(_: &'r Option<~TreeNode<K, V>>,
|
||||
_: &fn(&'r K, &'r V) -> bool) -> bool {
|
||||
fail!("don't use me in stage0!")
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
fn each<'r, K: TotalOrd, V>(node: &'r Option<~TreeNode<K, V>>,
|
||||
f: &fn(&'r K, &'r V) -> bool) -> bool {
|
||||
node.each(|x| each(&x.left, f) && f(&x.key, &x.value) &&
|
||||
each(&x.right, f))
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
fn each_reverse<'r, K: TotalOrd, V>(_: &'r Option<~TreeNode<K, V>>,
|
||||
_: &fn(&'r K, &'r V) -> bool) -> bool {
|
||||
fail!("don't use me in stage0!")
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
fn each_reverse<'r, K: TotalOrd, V>(node: &'r Option<~TreeNode<K, V>>,
|
||||
f: &fn(&'r K, &'r V) -> bool) -> bool {
|
||||
node.each(|x| each_reverse(&x.right, f) && f(&x.key, &x.value) &&
|
||||
|
@ -97,17 +97,6 @@ struct WorkKey {
|
||||
name: ~str
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for WorkKey {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
let mut flag = true;
|
||||
self.kind.iter_bytes(lsb0, |bytes| {flag = f(bytes); flag});
|
||||
if !flag { return; }
|
||||
self.name.iter_bytes(lsb0, f);
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for WorkKey {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
|
@ -79,20 +79,6 @@ static AbiDatas: &'static [AbiData] = &[
|
||||
AbiData {abi: RustIntrinsic, name: "rust-intrinsic", abi_arch: RustArch},
|
||||
];
|
||||
|
||||
#[cfg(stage0)]
|
||||
fn each_abi(op: &fn(abi: Abi) -> bool) {
|
||||
/*!
|
||||
*
|
||||
* Iterates through each of the defined ABIs.
|
||||
*/
|
||||
|
||||
for AbiDatas.each |abi_data| {
|
||||
if !op(abi_data.abi) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
fn each_abi(op: &fn(abi: Abi) -> bool) -> bool {
|
||||
/*!
|
||||
*
|
||||
@ -197,17 +183,6 @@ pub impl AbiSet {
|
||||
self.bits |= (1 << abi.index());
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
fn each(&self, op: &fn(abi: Abi) -> bool) {
|
||||
for each_abi |abi| {
|
||||
if self.contains(abi) {
|
||||
if !op(abi) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
fn each(&self, op: &fn(abi: Abi) -> bool) -> bool {
|
||||
each_abi(|abi| !self.contains(abi) || op(abi))
|
||||
}
|
||||
@ -265,26 +240,12 @@ pub impl AbiSet {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for Abi {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
self.index().iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for Abi {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
self.index().iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for AbiSet {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
self.bits.iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for AbiSet {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
self.bits.iter_bytes(lsb0, f)
|
||||
|
@ -95,14 +95,6 @@ impl<D:Decoder> Decodable<D> for ident {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for ident {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
self.repr.iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for ident {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
@ -120,14 +112,6 @@ pub struct Lifetime {
|
||||
ident: ident
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for Lifetime {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
to_bytes::iter_bytes_3(&self.id, &self.span, &self.ident, lsb0, f)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for Lifetime {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
to_bytes::iter_bytes_3(&self.id, &self.span, &self.ident, lsb0, f)
|
||||
@ -279,21 +263,6 @@ pub enum binding_mode {
|
||||
bind_infer
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for binding_mode {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
match *self {
|
||||
bind_by_copy => 0u8.iter_bytes(lsb0, f),
|
||||
|
||||
bind_by_ref(ref m) =>
|
||||
to_bytes::iter_bytes_2(&1u8, m, lsb0, f),
|
||||
|
||||
bind_infer =>
|
||||
2u8.iter_bytes(lsb0, f),
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for binding_mode {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
match *self {
|
||||
@ -334,13 +303,6 @@ pub enum pat_ {
|
||||
#[deriving(Eq, Encodable, Decodable)]
|
||||
pub enum mutability { m_mutbl, m_imm, m_const, }
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for mutability {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
(*self as u8).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for mutability {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
(*self as u8).iter_bytes(lsb0, f)
|
||||
@ -354,13 +316,6 @@ pub enum Sigil {
|
||||
ManagedSigil
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for Sigil {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
(*self as uint).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for Sigil {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
(*self as uint).iter_bytes(lsb0, f)
|
||||
@ -718,13 +673,6 @@ impl ToStr for int_ty {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for int_ty {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
(*self as u8).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for int_ty {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
(*self as u8).iter_bytes(lsb0, f)
|
||||
@ -740,13 +688,6 @@ impl ToStr for uint_ty {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for uint_ty {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
(*self as u8).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for uint_ty {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
(*self as u8).iter_bytes(lsb0, f)
|
||||
@ -762,13 +703,6 @@ impl ToStr for float_ty {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for float_ty {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
(*self as u8).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for float_ty {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
(*self as u8).iter_bytes(lsb0, f)
|
||||
@ -808,13 +742,6 @@ impl ToStr for Onceness {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for Onceness {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
(*self as uint).iter_bytes(lsb0, f);
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for Onceness {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
(*self as uint).iter_bytes(lsb0, f)
|
||||
@ -861,13 +788,6 @@ pub enum ty_ {
|
||||
ty_infer,
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for Ty {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
to_bytes::iter_bytes_2(&self.span.lo, &self.span.hi, lsb0, f);
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for Ty {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
to_bytes::iter_bytes_2(&self.span.lo, &self.span.hi, lsb0, f)
|
||||
@ -925,13 +845,6 @@ impl ToStr for purity {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for purity {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
(*self as u8).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for purity {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
(*self as u8).iter_bytes(lsb0, f)
|
||||
@ -945,13 +858,6 @@ pub enum ret_style {
|
||||
return_val, // everything else
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for ret_style {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
(*self as u8).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for ret_style {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
(*self as u8).iter_bytes(lsb0, f)
|
||||
@ -967,20 +873,6 @@ pub enum explicit_self_ {
|
||||
sty_uniq(mutability) // `~self`
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for explicit_self_ {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
match *self {
|
||||
sty_static => 0u8.iter_bytes(lsb0, f),
|
||||
sty_value => 1u8.iter_bytes(lsb0, f),
|
||||
sty_region(ref lft, ref mutbl) => to_bytes::iter_bytes_3(&2u8, &lft, mutbl, lsb0, f),
|
||||
sty_box(ref mutbl) => to_bytes::iter_bytes_2(&3u8, mutbl, lsb0, f),
|
||||
sty_uniq(ref mutbl) => to_bytes::iter_bytes_2(&4u8, mutbl, lsb0, f),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for explicit_self_ {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
match *self {
|
||||
|
@ -191,15 +191,6 @@ pub fn is_call_expr(e: @expr) -> bool {
|
||||
}
|
||||
|
||||
// This makes def_id hashable
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for def_id {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
to_bytes::iter_bytes_2(&self.crate, &self.node, lsb0, f);
|
||||
}
|
||||
}
|
||||
// This makes def_id hashable
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for def_id {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
|
@ -65,13 +65,6 @@ impl Sub<BytePos, BytePos> for BytePos {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for BytePos {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
(**self).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for BytePos {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
(**self).iter_bytes(lsb0, f)
|
||||
@ -90,13 +83,6 @@ impl cmp::Ord for CharPos {
|
||||
fn gt(&self, other: &CharPos) -> bool { **self > **other }
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for CharPos {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
(**self).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for CharPos {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
(**self).iter_bytes(lsb0, f)
|
||||
@ -150,14 +136,6 @@ impl<D:Decoder> Decodable<D> for span {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for span {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
to_bytes::iter_bytes_3(&self.lo, &self.hi, &self.expn_info, lsb0, f);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for span {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
to_bytes::iter_bytes_3(&self.lo, &self.hi, &self.expn_info, lsb0, f)
|
||||
@ -211,14 +189,6 @@ pub struct FileMapAndLine {fm: @FileMap, line: uint}
|
||||
pub struct FileMapAndBytePos {fm: @FileMap, pos: BytePos}
|
||||
pub struct NameAndSpan {name: ~str, span: Option<span>}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for NameAndSpan {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
to_bytes::iter_bytes_2(&self.name, &self.span, lsb0, f)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for NameAndSpan {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
to_bytes::iter_bytes_2(&self.name, &self.span, lsb0, f)
|
||||
@ -230,14 +200,6 @@ pub struct CallInfo {
|
||||
callee: NameAndSpan
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for CallInfo {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
to_bytes::iter_bytes_2(&self.call_site, &self.callee, lsb0, f)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for CallInfo {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
to_bytes::iter_bytes_2(&self.call_site, &self.callee, lsb0, f)
|
||||
@ -249,16 +211,6 @@ pub enum ExpnInfo {
|
||||
ExpandedFrom(CallInfo)
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for ExpnInfo {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
match *self {
|
||||
ExpandedFrom(ref call_info) => to_bytes::iter_bytes_2(&0u8, call_info, lsb0, f)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for ExpnInfo {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
match *self {
|
||||
|
@ -100,21 +100,6 @@ pub impl state_ {
|
||||
|
||||
/// Iterate over the states that can be reached in one message
|
||||
/// from this state.
|
||||
#[cfg(stage0)]
|
||||
fn reachable(&self, f: &fn(state) -> bool) {
|
||||
for self.messages.each |m| {
|
||||
match *m {
|
||||
message(_, _, _, _, Some(next_state { state: ref id, _ })) => {
|
||||
let state = self.proto.get_state((*id));
|
||||
if !f(state) { break }
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
}
|
||||
/// Iterate over the states that can be reached in one message
|
||||
/// from this state.
|
||||
#[cfg(not(stage0))]
|
||||
fn reachable(&self, f: &fn(state) -> bool) -> bool {
|
||||
for self.messages.each |m| {
|
||||
match *m {
|
||||
|
@ -130,14 +130,6 @@ impl<A:Eq> Eq for OptVec<A> {
|
||||
}
|
||||
|
||||
impl<A> BaseIter<A> for OptVec<A> {
|
||||
#[cfg(stage0)]
|
||||
fn each(&self, blk: &fn(v: &A) -> bool) {
|
||||
match *self {
|
||||
Empty => {}
|
||||
Vec(ref v) => v.each(blk)
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
fn each(&self, blk: &fn(v: &A) -> bool) -> bool {
|
||||
match *self {
|
||||
Empty => true,
|
||||
@ -152,12 +144,6 @@ impl<A> BaseIter<A> for OptVec<A> {
|
||||
|
||||
impl<A> old_iter::ExtendedIter<A> for OptVec<A> {
|
||||
#[inline(always)]
|
||||
#[cfg(stage0)]
|
||||
fn eachi(&self, blk: &fn(v: uint, v: &A) -> bool) {
|
||||
old_iter::eachi(self, blk)
|
||||
}
|
||||
#[inline(always)]
|
||||
#[cfg(not(stage0))]
|
||||
fn eachi(&self, blk: &fn(v: uint, v: &A) -> bool) -> bool {
|
||||
old_iter::eachi(self, blk)
|
||||
}
|
||||
|
@ -64,14 +64,6 @@ pub enum ObsoleteSyntax {
|
||||
ObsoleteNamedExternModule,
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for ObsoleteSyntax {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
(*self as uint).iter_bytes(lsb0, f);
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for ObsoleteSyntax {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
|
@ -349,14 +349,6 @@ impl<'self> Equiv<@~str> for StringRef<'self> {
|
||||
fn equiv(&self, other: &@~str) -> bool { str::eq_slice(**self, **other) }
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl<'self> to_bytes::IterBytes for StringRef<'self> {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
(**self).iter_bytes(lsb0, f);
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl<'self> to_bytes::IterBytes for StringRef<'self> {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
|
@ -1,3 +1,11 @@
|
||||
S 2013-05-17 2d28d64
|
||||
macos-i386 abadafb33c9f858543351c822fb468195163559f
|
||||
macos-x86_64 4a484693f73bcc8ce2a85708fd4f0c3f6e34969d
|
||||
winnt-i386 558dac018b2b6dbb23841772e1f4b9591558850c
|
||||
freebsd-x86_64 59ca6fc1eae2d160525c705928d551dd8993e01c
|
||||
linux-i386 2d3e61efe30f55176c72b3dbe31d693630f59abd
|
||||
linux-x86_64 86ecc1833df8e28d08ff3a9a952ec424abdcb157
|
||||
|
||||
S 2013-05-03 213f7b2
|
||||
macos-i386 0bf8b88ea01cc4cdd81ac4db1d301ea9b3371f13
|
||||
macos-x86_64 2da3990639ab5a9c9d51b3478c437cb459de84e3
|
||||
|
Loading…
Reference in New Issue
Block a user