diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2013-04-17 18:05:17 -0400 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2013-04-30 06:43:02 -0400 |
| commit | 202b8dcdc420d8b109fbd5260ea2e2be0a5b7faf (patch) | |
| tree | e83d223715ffe4b842f3a46b274b31ee3655ec50 /src/libcore | |
| parent | c081ffbd1e845687202a975ea2e698b623e5722f (diff) | |
| download | rust-202b8dcdc420d8b109fbd5260ea2e2be0a5b7faf.tar.gz rust-202b8dcdc420d8b109fbd5260ea2e2be0a5b7faf.zip | |
adapt to snapshot
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/container.rs | 36 | ||||
| -rw-r--r-- | src/libcore/hashmap.rs | 168 | ||||
| -rw-r--r-- | src/libcore/option.rs | 104 | ||||
| -rw-r--r-- | src/libcore/reflect.rs | 33 | ||||
| -rw-r--r-- | src/libcore/repr.rs | 110 | ||||
| -rw-r--r-- | src/libcore/result.rs | 7 | ||||
| -rw-r--r-- | src/libcore/rt/mod.rs | 21 | ||||
| -rw-r--r-- | src/libcore/rt/rtio.rs | 5 | ||||
| -rw-r--r-- | src/libcore/rt/uvio.rs | 16 | ||||
| -rw-r--r-- | src/libcore/trie.rs | 95 | ||||
| -rw-r--r-- | src/libcore/tuple.rs | 28 | ||||
| -rw-r--r-- | src/libcore/unstable/lang.rs | 26 | ||||
| -rw-r--r-- | src/libcore/vec.rs | 217 |
13 files changed, 2 insertions, 864 deletions
diff --git a/src/libcore/container.rs b/src/libcore/container.rs index 88c78aebfc5..00ea4a93221 100644 --- a/src/libcore/container.rs +++ b/src/libcore/container.rs @@ -25,42 +25,6 @@ pub trait Mutable: Container { fn clear(&mut self); } -#[cfg(stage0)] -pub trait Map<K, V>: Mutable { - /// Return true if the map contains a value for the specified key - fn contains_key(&self, key: &K) -> bool; - - // Visits all keys and values - fn each(&self, f: &fn(&K, &V) -> bool); - - /// Visit all keys - fn each_key(&self, f: &fn(&K) -> bool); - - /// Visit all values - fn each_value(&self, f: &fn(&V) -> bool); - - /// Iterate over the map and mutate the contained values - fn mutate_values(&mut self, f: &fn(&K, &mut V) -> bool); - - /// Return a reference to the value corresponding to the key - fn find(&self, key: &K) -> Option<&'self V>; - - /// Return a mutable reference to the value corresponding to the key - fn find_mut(&mut self, key: &K) -> Option<&'self mut V>; - - /// Insert a key-value pair into the map. An existing value for a - /// key is replaced by the new value. Return true if the key did - /// not already exist in the map. - fn insert(&mut self, key: K, value: V) -> bool; - - /// Remove a key-value pair from the map. Return true if the key - /// was present in the map, otherwise false. - fn remove(&mut self, key: &K) -> bool; -} - -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] pub trait Map<K, V>: Mutable { /// Return true if the map contains a value for the specified key fn contains_key(&self, key: &K) -> bool; diff --git a/src/libcore/hashmap.rs b/src/libcore/hashmap.rs index 41f4f34dc19..ad1994a92d2 100644 --- a/src/libcore/hashmap.rs +++ b/src/libcore/hashmap.rs @@ -184,18 +184,6 @@ priv impl<K:Hash + Eq,V> HashMap<K, V> { } } - #[cfg(stage0)] - #[inline(always)] - fn value_for_bucket(&self, idx: uint) -> &'self V { - match self.buckets[idx] { - Some(ref bkt) => &bkt.value, - None => fail!(~"HashMap::find: internal logic error"), - } - } - - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] #[inline(always)] fn value_for_bucket<'a>(&'a self, idx: uint) -> &'a V { match self.buckets[idx] { @@ -204,18 +192,6 @@ priv impl<K:Hash + Eq,V> HashMap<K, V> { } } - #[cfg(stage0)] - #[inline(always)] - fn mut_value_for_bucket(&mut self, idx: uint) -> &'self mut V { - match self.buckets[idx] { - Some(ref mut bkt) => &mut bkt.value, - None => unreachable() - } - } - - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] #[inline(always)] fn mut_value_for_bucket<'a>(&'a mut self, idx: uint) -> &'a mut V { match self.buckets[idx] { @@ -329,21 +305,6 @@ impl<K:Hash + Eq,V> Map<K, V> for HashMap<K, V> { } /// Visit all key-value pairs - #[cfg(stage0)] - fn each(&self, blk: &fn(&'self K, &'self 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(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn each<'a>(&'a self, blk: &fn(&'a K, &'a V) -> bool) { for uint::range(0, self.buckets.len()) |i| { for self.buckets[i].each |bucket| { @@ -360,15 +321,6 @@ impl<K:Hash + Eq,V> Map<K, V> for HashMap<K, V> { } /// Visit all values - #[cfg(stage0)] - fn each_value(&self, blk: &fn(v: &V) -> bool) { - self.each(|_, v| blk(v)) - } - - /// Visit all values - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn each_value<'a>(&'a self, blk: &fn(v: &'a V) -> bool) { self.each(|_, v| blk(v)) } @@ -386,18 +338,6 @@ impl<K:Hash + Eq,V> Map<K, V> for HashMap<K, V> { } /// Return a reference to the value corresponding to the key - #[cfg(stage0)] - fn find(&self, k: &K) -> Option<&'self V> { - match self.bucket_for_key(k) { - FoundEntry(idx) => Some(self.value_for_bucket(idx)), - TableFull | FoundHole(_) => None, - } - } - - /// Return a reference to the value corresponding to the key - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn find<'a>(&'a self, k: &K) -> Option<&'a V> { match self.bucket_for_key(k) { FoundEntry(idx) => Some(self.value_for_bucket(idx)), @@ -406,21 +346,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(&mut self, k: &K) -> Option<&'self mut V> { - let idx = match self.bucket_for_key(k) { - FoundEntry(idx) => idx, - TableFull | FoundHole(_) => return None - }; - unsafe { // FIXME(#4903)---requires flow-sensitive borrow checker - Some(::cast::transmute_mut_region(self.mut_value_for_bucket(idx))) - } - } - - /// Return a mutable reference to the value corresponding to the key - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn find_mut<'a>(&'a mut self, k: &K) -> Option<&'a mut V> { let idx = match self.bucket_for_key(k) { FoundEntry(idx) => idx, @@ -503,40 +428,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(&mut self, k: K, v: V) -> &'self 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 { // FIXME(#4903)---requires flow-sensitive borrow checker - ::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(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] 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 @@ -567,41 +458,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(&mut self, k: K, f: &fn(&K) -> V) -> &'self 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 { // FIXME(#4903)---requires flow-sensitive borrow checker - ::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(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] 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 @@ -647,17 +503,6 @@ pub impl<K: Hash + Eq, V> HashMap<K, V> { } } - #[cfg(stage0)] - fn get(&self, k: &K) -> &'self V { - match self.find(k) { - Some(v) => v, - None => fail!(fmt!("No entry found for key: %?", k)), - } - } - - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn get<'a>(&'a self, k: &K) -> &'a V { match self.find(k) { Some(v) => v, @@ -676,19 +521,6 @@ pub impl<K: Hash + Eq, V> HashMap<K, V> { /// Return the value corresponding to the key in the map, using /// equivalence - #[cfg(stage0)] - fn find_equiv<Q:Hash + Equiv<K>>(&self, k: &Q) -> Option<&'self V> { - match self.bucket_for_key_equiv(k) { - FoundEntry(idx) => Some(self.value_for_bucket(idx)), - TableFull | FoundHole(_) => None, - } - } - - /// Return the value corresponding to the key in the map, using - /// equivalence - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn find_equiv<'a, Q:Hash + Equiv<K>>(&'a self, k: &Q) -> Option<&'a V> { match self.bucket_for_key_equiv(k) { FoundEntry(idx) => Some(self.value_for_bucket(idx)), diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 17192b4257b..5abf376ddde 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -100,16 +100,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 - #[cfg(stage0)] - #[inline(always)] - fn each(&self, f: &fn(x: &'self T) -> bool) { - match *self { None => (), Some(ref t) => { f(t); } } - } - - /// Performs an operation on the contained value by reference - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] #[inline(always)] fn each<'a>(&'a self, f: &fn(x: &'a T) -> bool) { match *self { None => (), Some(ref t) => { f(t); } } @@ -122,15 +112,6 @@ impl<T> BaseIter<T> for Option<T> { } impl<T> MutableIter<T> for Option<T> { - #[cfg(stage0)] - #[inline(always)] - fn each_mut(&mut self, f: &fn(&'self mut T) -> bool) { - match *self { None => (), Some(ref mut t) => { f(t); } } - } - - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] #[inline(always)] fn each_mut<'a>(&'a mut self, f: &fn(&'a mut T) -> bool) { match *self { None => (), Some(ref mut t) => { f(t); } } @@ -200,35 +181,12 @@ pub impl<T> Option<T> { * Update an optional value by optionally running its content by reference * through a function that returns an option. */ - #[cfg(stage0)] - #[inline(always)] - fn chain_ref<U>(&self, f: &fn(x: &'self T) -> Option<U>) -> Option<U> { - match *self { Some(ref x) => f(x), None => None } - } - - /** - * Update an optional value by optionally running its content by reference - * through a function that returns an option. - */ - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] #[inline(always)] fn chain_ref<'a, U>(&'a self, f: &fn(x: &'a T) -> Option<U>) -> Option<U> { match *self { Some(ref x) => f(x), None => None } } /// Maps a `some` value from one type to another by reference - #[cfg(stage0)] - #[inline(always)] - fn map<U>(&self, f: &fn(&'self T) -> U) -> Option<U> { - match *self { Some(ref x) => Some(f(x)), None => None } - } - - /// Maps a `some` value from one type to another by reference - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] #[inline(always)] fn map<'a, U>(&self, f: &fn(&'a T) -> U) -> Option<U> { match *self { Some(ref x) => Some(f(x)), None => None } @@ -242,16 +200,6 @@ pub impl<T> Option<T> { } /// Applies a function to the contained value or returns a default - #[cfg(stage0)] - #[inline(always)] - fn map_default<U>(&self, def: U, f: &fn(&'self T) -> U) -> U { - match *self { None => def, Some(ref t) => f(t) } - } - - /// Applies a function to the contained value or returns a default - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] #[inline(always)] fn map_default<'a, U>(&'a self, def: U, f: &fn(&'a T) -> U) -> U { match *self { None => def, Some(ref t) => f(t) } @@ -295,32 +243,6 @@ pub impl<T> Option<T> { case explicitly. */ #[inline(always)] - #[cfg(stage0)] - fn get_ref(&self) -> &'self T { - match *self { - Some(ref x) => x, - None => fail!(~"option::get_ref none") - } - } - - /** - Gets an immutable reference to the value inside an option. - - # Failure - - Fails if the value equals `None` - - # Safety note - - In general, because this function may fail, its use is discouraged - (calling `get` on `None` is akin to dereferencing a null pointer). - Instead, prefer to use pattern matching and handle the `None` - case explicitly. - */ - #[inline(always)] - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn get_ref<'a>(&'a self) -> &'a T { match *self { Some(ref x) => x, @@ -343,32 +265,6 @@ pub impl<T> Option<T> { case explicitly. */ #[inline(always)] - #[cfg(stage0)] - fn get_mut_ref(&mut self) -> &'self mut T { - match *self { - Some(ref mut x) => x, - None => fail!(~"option::get_mut_ref none") - } - } - - /** - Gets a mutable reference to the value inside an option. - - # Failure - - Fails if the value equals `None` - - # Safety note - - In general, because this function may fail, its use is discouraged - (calling `get` on `None` is akin to dereferencing a null pointer). - Instead, prefer to use pattern matching and handle the `None` - case explicitly. - */ - #[inline(always)] - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn get_mut_ref<'a>(&'a mut self) -> &'a mut T { match *self { Some(ref mut x) => x, diff --git a/src/libcore/reflect.rs b/src/libcore/reflect.rs index 9a0526b4351..47de360f589 100644 --- a/src/libcore/reflect.rs +++ b/src/libcore/reflect.rs @@ -15,7 +15,7 @@ Runtime type reflection */ use intrinsic::{TyDesc, TyVisitor}; -#[cfg(not(stage0))] use intrinsic::Opaque; +use intrinsic::Opaque; use libc::c_void; use sys; use vec; @@ -394,17 +394,6 @@ impl<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> { true } - #[cfg(stage0)] - fn visit_enter_enum(&self, n_variants: uint, sz: uint, align: uint) - -> bool { - self.align(align); - if ! self.inner.visit_enter_enum(n_variants, sz, align) { - return false; - } - true - } - - #[cfg(not(stage0))] fn visit_enter_enum(&self, n_variants: uint, get_disr: extern unsafe fn(ptr: *Opaque) -> int, sz: uint, align: uint) @@ -428,15 +417,6 @@ impl<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> { true } - #[cfg(stage0)] - fn visit_enum_variant_field(&self, i: uint, inner: *TyDesc) -> bool { - unsafe { self.align((*inner).align); } - if ! self.inner.visit_enum_variant_field(i, inner) { return false; } - unsafe { self.bump((*inner).size); } - true - } - - #[cfg(not(stage0))] fn visit_enum_variant_field(&self, i: uint, offset: uint, inner: *TyDesc) -> bool { self.inner.push_ptr(); self.bump(offset); @@ -457,17 +437,6 @@ impl<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> { true } - #[cfg(stage0)] - fn visit_leave_enum(&self, n_variants: uint, sz: uint, align: uint) - -> bool { - if ! self.inner.visit_leave_enum(n_variants, sz, align) { - return false; - } - self.bump(sz); - true - } - - #[cfg(not(stage0))] fn visit_leave_enum(&self, n_variants: uint, get_disr: extern unsafe fn(ptr: *Opaque) -> int, sz: uint, align: uint) -> bool { diff --git a/src/libcore/repr.rs b/src/libcore/repr.rs index 03e44e00d88..2d6412b0cc8 100644 --- a/src/libcore/repr.rs +++ b/src/libcore/repr.rs @@ -18,7 +18,7 @@ use cast::transmute; use char; use intrinsic; use intrinsic::{TyDesc, TyVisitor, visit_tydesc}; -#[cfg(not(stage0))] use intrinsic::Opaque; +use intrinsic::Opaque; use io::{Writer, WriterUtil}; use libc::c_void; use managed; @@ -138,14 +138,6 @@ impl Repr for char { // New implementation using reflect::MovePtr -#[cfg(stage0)] -enum VariantState { - Degenerate, - TagMatch, - TagMismatch, -} - -#[cfg(not(stage0))] enum VariantState { SearchingFor(int), Matched, @@ -190,18 +182,6 @@ pub impl ReprVisitor { true } - #[cfg(stage0)] #[inline(always)] - fn bump(&self, sz: uint) { - do self.move_ptr() |p| { - ((p as uint) + sz) as *c_void - }; - } - - #[cfg(stage0)] #[inline(always)] - fn bump_past<T>(&self) { - self.bump(sys::size_of::<T>()); - } - #[inline(always)] fn visit_inner(&self, inner: *TyDesc) -> bool { self.visit_ptr_inner(self.ptr, inner) @@ -467,18 +447,6 @@ impl TyVisitor for ReprVisitor { true } - #[cfg(stage0)] - fn visit_enter_enum(&self, n_variants: uint, - _sz: uint, _align: uint) -> bool { - if n_variants == 1 { - self.var_stk.push(Degenerate) - } else { - self.var_stk.push(TagMatch) - } - true - } - - #[cfg(not(stage0))] fn visit_enter_enum(&self, _n_variants: uint, get_disr: extern unsafe fn(ptr: *Opaque) -> int, _sz: uint, _align: uint) -> bool { @@ -487,40 +455,6 @@ impl TyVisitor for ReprVisitor { true } - #[cfg(stage0)] - fn visit_enter_enum_variant(&self, _variant: uint, - disr_val: int, - n_fields: uint, - name: &str) -> bool { - let mut write = false; - match self.var_stk.pop() { - Degenerate => { - write = true; - self.var_stk.push(Degenerate); - } - TagMatch | TagMismatch => { - do self.get::<int>() |t| { - if disr_val == *t { - write = true; - self.var_stk.push(TagMatch); - } else { - self.var_stk.push(TagMismatch); - } - }; - self.bump_past::<int>(); - } - } - - if write { - self.writer.write_str(name); - if n_fields > 0 { - self.writer.write_char('('); - } - } - true - } - - #[cfg(not(stage0))] fn visit_enter_enum_variant(&self, _variant: uint, disr_val: int, n_fields: uint, @@ -549,23 +483,6 @@ impl TyVisitor for ReprVisitor { true } - #[cfg(stage0)] - fn visit_enum_variant_field(&self, i: uint, inner: *TyDesc) -> bool { - match self.var_stk[vec::uniq_len(&const self.var_stk) - 1] { - Degenerate | TagMatch => { - if i != 0 { - self.writer.write_str(", "); - } - if ! self.visit_inner(inner) { - return false; - } - } - TagMismatch => () - } - true - } - - #[cfg(not(stage0))] fn visit_enum_variant_field(&self, i: uint, _offset: uint, inner: *TyDesc) -> bool { match self.var_stk[vec::uniq_len(&const self.var_stk) - 1] { Matched => { @@ -581,23 +498,6 @@ impl TyVisitor for ReprVisitor { true } - #[cfg(stage0)] - fn visit_leave_enum_variant(&self, _variant: uint, - _disr_val: int, - n_fields: uint, - _name: &str) -> bool { - match self.var_stk[vec::uniq_len(&const self.var_stk) - 1] { - Degenerate | TagMatch => { - if n_fields > 0 { - self.writer.write_char(')'); - } - } - TagMismatch => () - } - true - } - - #[cfg(not(stage0))] fn visit_leave_enum_variant(&self, _variant: uint, _disr_val: int, n_fields: uint, @@ -613,14 +513,6 @@ impl TyVisitor for ReprVisitor { true } - #[cfg(stage0)] - fn visit_leave_enum(&self, _n_variants: uint, - _sz: uint, _align: uint) -> bool { - self.var_stk.pop(); - true - } - - #[cfg(not(stage0))] fn visit_leave_enum(&self, _n_variants: uint, _get_disr: extern unsafe fn(ptr: *Opaque) -> int, _sz: uint, _align: uint) -> bool { diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 9171c5167bc..17cc07c660d 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -226,13 +226,6 @@ pub fn map_err<T:Copy,E,F:Copy>(res: &Result<T, E>, op: &fn(&E) -> F) } pub impl<T, E> Result<T, E> { - #[cfg(stage0)] - #[inline(always)] - fn get_ref(&self) -> &'self T { get_ref(self) } - - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] #[inline(always)] fn get_ref<'a>(&'a self) -> &'a T { get_ref(self) } diff --git a/src/libcore/rt/mod.rs b/src/libcore/rt/mod.rs index e93e0c6fc6c..e77ec82637e 100644 --- a/src/libcore/rt/mod.rs +++ b/src/libcore/rt/mod.rs @@ -49,27 +49,6 @@ mod context; mod thread; pub mod env; -#[cfg(stage0)] -pub fn start(main: *u8, _argc: int, _argv: *c_char, _crate_map: *u8) -> int { - use self::sched::{Scheduler, Task}; - use self::uvio::UvEventLoop; - - let loop_ = ~UvEventLoop::new(); - let mut sched = ~Scheduler::new(loop_); - let main_task = ~do Task::new(&mut sched.stack_pool) { - // XXX: Can't call a C function pointer from Rust yet - unsafe { rust_call_nullary_fn(main) }; - }; - sched.task_queue.push_back(main_task); - sched.run(); - return 0; - - extern { - fn rust_call_nullary_fn(f: *u8); - } -} - -#[cfg(not(stage0))] pub fn start(main: *u8, _argc: int, _argv: **c_char, _crate_map: *u8) -> int { use self::sched::{Scheduler, Task}; use self::uvio::UvEventLoop; diff --git a/src/libcore/rt/rtio.rs b/src/libcore/rt/rtio.rs index 66eb79ba6ae..fd64438c61b 100644 --- a/src/libcore/rt/rtio.rs +++ b/src/libcore/rt/rtio.rs @@ -24,11 +24,6 @@ pub trait EventLoop { fn run(&mut self); fn callback(&mut self, ~fn()); /// The asynchronous I/O services. Not all event loops may provide one - #[cfg(stage0)] - fn io(&mut self) -> Option<&'self mut IoFactoryObject>; - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn io<'a>(&'a mut self) -> Option<&'a mut IoFactoryObject>; } diff --git a/src/libcore/rt/uvio.rs b/src/libcore/rt/uvio.rs index abdd8d6619a..fba91dd7d8a 100644 --- a/src/libcore/rt/uvio.rs +++ b/src/libcore/rt/uvio.rs @@ -69,14 +69,6 @@ impl EventLoop for UvEventLoop { } } - #[cfg(stage0)] - fn io(&mut self) -> Option<&'self mut IoFactoryObject> { - Some(&mut self.uvio) - } - - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn io<'a>(&'a mut self) -> Option<&'a mut IoFactoryObject> { Some(&mut self.uvio) } @@ -99,14 +91,6 @@ fn test_callback_run_once() { pub struct UvIoFactory(Loop); pub impl UvIoFactory { - #[cfg(stage0)] - fn uv_loop(&mut self) -> &'self mut Loop { - match self { &UvIoFactory(ref mut ptr) => ptr } - } - - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn uv_loop<'a>(&'a mut self) -> &'a mut Loop { match self { &UvIoFactory(ref mut ptr) => ptr } } diff --git a/src/libcore/trie.rs b/src/libcore/trie.rs index f4e9ddbdd90..f0756be9944 100644 --- a/src/libcore/trie.rs +++ b/src/libcore/trie.rs @@ -56,16 +56,6 @@ impl<T> Map<uint, T> for TrieMap<T> { /// Visit all key-value pairs in order #[inline(always)] - #[cfg(stage0)] - fn each(&self, f: &fn(&uint, &'self T) -> bool) { - self.root.each(f); - } - - /// Visit all key-value pairs in order - #[inline(always)] - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn each<'a>(&'a self, f: &fn(&uint, &'a T) -> bool) { self.root.each(f); } @@ -78,16 +68,6 @@ impl<T> Map<uint, T> for TrieMap<T> { /// Visit all values in order #[inline(always)] - #[cfg(stage0)] - fn each_value(&self, f: &fn(&T) -> bool) { - self.each(|_, v| f(v)) - } - - /// Visit all values in order - #[inline(always)] - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn each_value<'a>(&'a self, f: &fn(&'a T) -> bool) { self.each(|_, v| f(v)) } @@ -99,31 +79,6 @@ impl<T> Map<uint, T> for TrieMap<T> { } /// Return a reference to the value corresponding to the key - #[cfg(stage0)] - #[inline(hint)] - fn find(&self, key: &uint) -> Option<&'self T> { - let mut node: &'self TrieNode<T> = &self.root; - let mut idx = 0; - loop { - match node.children[chunk(*key, idx)] { - Internal(ref x) => node = &**x, - External(stored, ref value) => { - if stored == *key { - return Some(value) - } else { - return None - } - } - Nothing => return None - } - idx += 1; - } - } - - /// Return a reference to the value corresponding to the key - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] #[inline(hint)] fn find<'a>(&'a self, key: &uint) -> Option<&'a T> { let mut node: &'a TrieNode<T> = &self.root; @@ -145,16 +100,6 @@ impl<T> Map<uint, T> for TrieMap<T> { } /// Return a mutable reference to the value corresponding to the key - #[cfg(stage0)] - #[inline(always)] - fn find_mut(&mut self, key: &uint) -> Option<&'self mut T> { - find_mut(&mut self.root.children[chunk(*key, 0)], *key, 1) - } - - /// Return a mutable reference to the value corresponding to the key - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] #[inline(always)] fn find_mut<'a>(&'a mut self, key: &uint) -> Option<&'a mut T> { find_mut(&mut self.root.children[chunk(*key, 0)], *key, 1) @@ -193,16 +138,6 @@ pub impl<T> TrieMap<T> { /// Visit all key-value pairs in reverse order #[inline(always)] - #[cfg(stage0)] - fn each_reverse(&self, f: &fn(&uint, &'self T) -> bool) { - self.root.each_reverse(f); - } - - /// Visit all key-value pairs in reverse order - #[inline(always)] - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn each_reverse<'a>(&'a self, f: &fn(&uint, &'a T) -> bool) { self.root.each_reverse(f); } @@ -298,21 +233,6 @@ impl<T> TrieNode<T> { } impl<T> TrieNode<T> { - #[cfg(stage0)] - fn each(&self, f: &fn(&uint, &'self T) -> bool) -> bool { - for uint::range(0, self.children.len()) |idx| { - match self.children[idx] { - Internal(ref x) => if !x.each(f) { return false }, - External(k, ref v) => if !f(&k, v) { return false }, - Nothing => () - } - } - true - } - - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn each<'a>(&'a self, f: &fn(&uint, &'a T) -> bool) -> bool { for uint::range(0, self.children.len()) |idx| { match self.children[idx] { @@ -324,21 +244,6 @@ impl<T> TrieNode<T> { true } - #[cfg(stage0)] - fn each_reverse(&self, f: &fn(&uint, &'self T) -> bool) -> bool { - for uint::range_rev(self.children.len(), 0) |idx| { - match self.children[idx - 1] { - Internal(ref x) => if !x.each_reverse(f) { return false }, - External(k, ref v) => if !f(&k, v) { return false }, - Nothing => () - } - } - true - } - - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn each_reverse<'a>(&'a self, f: &fn(&uint, &'a T) -> bool) -> bool { for uint::range_rev(self.children.len(), 0) |idx| { match self.children[idx - 1] { diff --git a/src/libcore/tuple.rs b/src/libcore/tuple.rs index a2b6f0eb1a7..6da22657906 100644 --- a/src/libcore/tuple.rs +++ b/src/libcore/tuple.rs @@ -56,39 +56,11 @@ impl<T:Clone,U:Clone> Clone for (T, U) { } } -#[cfg(stage0)] -pub trait ImmutableTuple<T, U> { - fn first_ref(&self) -> &'self T; - fn second_ref(&self) -> &'self U; -} - -#[cfg(stage0)] -impl<T, U> ImmutableTuple<T, U> for (T, U) { - #[inline(always)] - fn first_ref(&self) -> &'self T { - match *self { - (ref t, _) => t, - } - } - #[inline(always)] - fn second_ref(&self) -> &'self U { - match *self { - (_, ref u) => u, - } - } -} - -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] pub trait ImmutableTuple<T, U> { fn first_ref<'a>(&'a self) -> &'a T; fn second_ref<'a>(&'a self) -> &'a U; } -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] impl<T, U> ImmutableTuple<T, U> for (T, U) { #[inline(always)] fn first_ref<'a>(&'a self) -> &'a T { diff --git a/src/libcore/unstable/lang.rs b/src/libcore/unstable/lang.rs index 611862a79e7..de0542afc39 100644 --- a/src/libcore/unstable/lang.rs +++ b/src/libcore/unstable/lang.rs @@ -135,32 +135,6 @@ pub unsafe fn strdup_uniq(ptr: *c_uchar, len: uint) -> ~str { } #[lang="start"] -#[cfg(stage0)] -pub fn start(main: *u8, argc: int, argv: *c_char, - crate_map: *u8) -> int { - use libc::getenv; - use rt::start; - - unsafe { - let use_old_rt = do str::as_c_str("RUST_NEWRT") |s| { - getenv(s).is_null() - }; - if use_old_rt { - return rust_start(main as *c_void, argc as c_int, argv, - crate_map as *c_void) as int; - } else { - return start(main, argc, argv, crate_map); - } - } - - extern { - fn rust_start(main: *c_void, argc: c_int, argv: *c_char, - crate_map: *c_void) -> c_int; - } -} - -#[lang="start"] -#[cfg(not(stage0))] pub fn start(main: *u8, argc: int, argv: **c_char, crate_map: *u8) -> int { use libc::getenv; diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index 86767dc5bad..94f86664353 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -1566,16 +1566,6 @@ pub fn each_permutation<T:Copy>(v: &[T], put: &fn(ts: &[T]) -> bool) { } } -// see doc below -#[cfg(stage0)] // XXX: lifetimes! -pub fn windowed<T>(n: uint, v: &[T], it: &fn(&[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`. * @@ -1590,9 +1580,6 @@ pub fn windowed<T>(n: uint, v: &[T], it: &fn(&[T]) -> bool) { * ~~~ * */ -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] pub fn windowed<'r, T>(n: uint, v: &'r [T], it: &fn(&'r [T]) -> bool) { assert!(1u <= n); if n > v.len() { return; } @@ -1854,150 +1841,6 @@ impl<'self,T:Copy> CopyableVector<T> for &'self const [T] { } } -#[cfg(stage0)] -pub trait ImmutableVector<T> { - fn slice(&self, start: uint, end: uint) -> &'self [T]; - fn head(&self) -> &'self T; - fn head_opt(&self) -> Option<&'self T>; - fn tail(&self) -> &'self [T]; - fn tailn(&self, n: uint) -> &'self [T]; - fn init(&self) -> &'self [T]; - fn initn(&self, n: uint) -> &'self [T]; - fn last(&self) -> &'self T; - fn last_opt(&self) -> Option<&'self T>; - fn each_reverse(&self, blk: &fn(&T) -> bool); - fn eachi_reverse(&self, blk: &fn(uint, &T) -> bool); - fn foldr<U: Copy>(&self, z: U, p: &fn(t: &T, u: U) -> U) -> U; - fn map<U>(&self, f: &fn(t: &T) -> U) -> ~[U]; - fn mapi<U>(&self, f: &fn(uint, t: &T) -> U) -> ~[U]; - fn map_r<U>(&self, f: &fn(x: &T) -> U) -> ~[U]; - fn alli(&self, f: &fn(uint, t: &T) -> bool) -> bool; - fn flat_map<U>(&self, f: &fn(t: &T) -> ~[U]) -> ~[U]; - fn filter_mapped<U:Copy>(&self, f: &fn(t: &T) -> Option<U>) -> ~[U]; - unsafe fn unsafe_ref(&self, index: uint) -> *T; -} - -/// Extension methods for vectors -#[cfg(stage0)] -impl<'self,T> ImmutableVector<T> for &'self [T] { - /// Return a slice that points into another slice. - #[inline] - fn slice(&self, start: uint, end: uint) -> &'self [T] { - slice(*self, start, end) - } - - /// Returns the first element of a vector, failing if the vector is empty. - #[inline] - fn head(&self) -> &'self T { head(*self) } - - /// Returns the first element of a vector - #[inline] - fn head_opt(&self) -> Option<&'self T> { head_opt(*self) } - - /// Returns all but the first element of a vector - #[inline] - fn tail(&self) -> &'self [T] { tail(*self) } - - /// Returns all but the first `n' elements of a vector - #[inline] - fn tailn(&self, n: uint) -> &'self [T] { tailn(*self, n) } - - /// Returns all but the last elemnt of a vector - #[inline] - fn init(&self) -> &'self [T] { init(*self) } - - /// Returns all but the last `n' elemnts of a vector - #[inline] - fn initn(&self, n: uint) -> &'self [T] { initn(*self, n) } - - /// Returns the last element of a `v`, failing if the vector is empty. - #[inline] - fn last(&self) -> &'self T { last(*self) } - - /// Returns the last element of a `v`, failing if the vector is empty. - #[inline] - fn last_opt(&self) -> Option<&'self T> { last_opt(*self) } - - /// Iterates over a vector's elements in reverse. - #[inline] - fn each_reverse(&self, blk: &fn(&T) -> bool) { - each_reverse(*self, blk) - } - - /// Iterates over a vector's elements and indices in reverse. - #[inline] - fn eachi_reverse(&self, blk: &fn(uint, &T) -> bool) { - eachi_reverse(*self, blk) - } - - /// Reduce a vector from right to left - #[inline] - fn foldr<U:Copy>(&self, z: U, p: &fn(t: &T, u: U) -> U) -> U { - foldr(*self, z, p) - } - - /// Apply a function to each element of a vector and return the results - #[inline] - fn map<U>(&self, f: &fn(t: &T) -> U) -> ~[U] { map(*self, f) } - - /** - * Apply a function to the index and value of each element in the vector - * and return the results - */ - fn mapi<U>(&self, f: &fn(uint, t: &T) -> U) -> ~[U] { - mapi(*self, f) - } - - #[inline] - fn map_r<U>(&self, f: &fn(x: &T) -> U) -> ~[U] { - let mut r = ~[]; - let mut i = 0; - while i < self.len() { - r.push(f(&self[i])); - i += 1; - } - r - } - - /** - * Returns true if the function returns true for all elements. - * - * If the vector is empty, true is returned. - */ - fn alli(&self, f: &fn(uint, t: &T) -> bool) -> bool { - alli(*self, f) - } - /** - * Apply a function to each element of a vector and return a concatenation - * of each result vector - */ - #[inline] - fn flat_map<U>(&self, f: &fn(t: &T) -> ~[U]) -> ~[U] { - flat_map(*self, f) - } - /** - * Apply a function to each element of a vector and return the results - * - * If function `f` returns `none` then that element is excluded from - * the resulting vector. - */ - #[inline] - fn filter_mapped<U:Copy>(&self, f: &fn(t: &T) -> Option<U>) -> ~[U] { - filter_mapped(*self, f) - } - - /// Returns a pointer to the element at the given index, without doing - /// bounds checking. - #[inline(always)] - unsafe fn unsafe_ref(&self, index: uint) -> *T { - let (ptr, _): (*T, uint) = transmute(*self); - ptr.offset(index) - } -} - -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] pub trait ImmutableVector<'self, T> { fn slice(&self, start: uint, end: uint) -> &'self [T]; fn iter(self) -> VecIterator<'self, T>; @@ -2022,9 +1865,6 @@ pub trait ImmutableVector<'self, T> { } /// Extension methods for vectors -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] impl<'self,T> ImmutableVector<'self, T> for &'self [T] { /// Return a slice that points into another slice. #[inline] @@ -2634,17 +2474,6 @@ pub mod bytes { // ___________________________________________________________________________ // ITERATION TRAIT METHODS -#[cfg(stage0)] -impl<'self,A> old_iter::BaseIter<A> for &'self [A] { - #[inline(always)] - fn each(&self, blk: &fn(v: &'self A) -> bool) { each(*self, blk) } - #[inline(always)] - fn size_hint(&self) -> Option<uint> { Some(self.len()) } -} - -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] impl<'self,A> old_iter::BaseIter<A> for &'self [A] { #[inline(always)] fn each<'a>(&'a self, blk: &fn(v: &'a A) -> bool) { each(*self, blk) } @@ -2653,18 +2482,6 @@ impl<'self,A> old_iter::BaseIter<A> for &'self [A] { } // FIXME(#4148): This should be redundant -#[cfg(stage0)] -impl<A> old_iter::BaseIter<A> for ~[A] { - #[inline(always)] - fn each(&self, blk: &fn(v: &'self A) -> bool) { each(*self, blk) } - #[inline(always)] - fn size_hint(&self) -> Option<uint> { Some(self.len()) } -} - -// FIXME(#4148): This should be redundant -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] impl<A> old_iter::BaseIter<A> for ~[A] { #[inline(always)] fn each<'a>(&'a self, blk: &fn(v: &'a A) -> bool) { each(*self, blk) } @@ -2673,18 +2490,6 @@ impl<A> old_iter::BaseIter<A> for ~[A] { } // FIXME(#4148): This should be redundant -#[cfg(stage0)] -impl<A> old_iter::BaseIter<A> for @[A] { - #[inline(always)] - fn each(&self, blk: &fn(v: &'self A) -> bool) { each(*self, blk) } - #[inline(always)] - fn size_hint(&self) -> Option<uint> { Some(self.len()) } -} - -// FIXME(#4148): This should be redundant -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] impl<A> old_iter::BaseIter<A> for @[A] { #[inline(always)] fn each<'a>(&'a self, blk: &fn(v: &'a A) -> bool) { each(*self, blk) } @@ -2692,17 +2497,6 @@ impl<A> old_iter::BaseIter<A> for @[A] { fn size_hint(&self) -> Option<uint> { Some(self.len()) } } -#[cfg(stage0)] -impl<'self,A> old_iter::MutableIter<A> for &'self mut [A] { - #[inline(always)] - fn each_mut(&mut self, blk: &fn(v: &'self mut A) -> bool) { - each_mut(*self, blk) - } -} - -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] impl<'self,A> old_iter::MutableIter<A> for &'self mut [A] { #[inline(always)] fn each_mut<'a>(&'a mut self, blk: &fn(v: &'a mut A) -> bool) { @@ -2711,17 +2505,6 @@ impl<'self,A> old_iter::MutableIter<A> for &'self mut [A] { } // FIXME(#4148): This should be redundant -#[cfg(stage0)] -impl<A> old_iter::MutableIter<A> for ~[A] { - #[inline(always)] - fn each_mut(&mut self, blk: &fn(v: &'self mut A) -> bool) { - each_mut(*self, blk) - } -} - -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] impl<A> old_iter::MutableIter<A> for ~[A] { #[inline(always)] fn each_mut<'a>(&'a mut self, blk: &fn(v: &'a mut A) -> bool) { |
