auto merge of #6223 : alexcrichton/rust/issue-6183, r=pcwalton

Closes #6183.

The first commit changes the compiler's method of treating a `for` loop, and all the remaining commits are just dealing with the fallout.

The biggest fallout was the `IterBytes` trait, although it's really a whole lot nicer now because all of the `iter_bytes_XX` methods are just and-ed together. Sadly there was a huge amount of stuff that's `cfg(stage0)` gated, but whoever lands the next snapshot is going to have a lot of fun deleting all this code!
This commit is contained in:
bors 2013-05-10 17:56:02 -07:00
commit 3e0400fb86
73 changed files with 2948 additions and 309 deletions

View file

@ -200,6 +200,7 @@ pub mod reader {
}
}
#[cfg(stage0)]
pub fn docs(d: Doc, it: &fn(uint, Doc) -> bool) {
let mut pos = d.start;
while pos < d.end {
@ -212,7 +213,22 @@ pub mod reader {
}
}
}
#[cfg(not(stage0))]
pub fn docs(d: Doc, it: &fn(uint, Doc) -> bool) -> 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) {
return false;
}
}
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 {
@ -228,6 +244,23 @@ pub mod reader {
}
}
}
#[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 {
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) {
return false;
}
}
}
return true;
}
pub fn doc_data(d: Doc) -> ~[u8] {
vec::slice::<u8>(*d.data, d.start, d.end).to_vec()