Skip to content

Commit b4ef5ee

Browse files
committed
---
yaml --- r: 97755 b: refs/heads/snap-stage3 c: 7d75bbf h: refs/heads/master i: 97753: 981318e 97751: 39554b9 v: v3
1 parent 3f2c7cc commit b4ef5ee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1212
-554
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 0da105a8b7b6b1e0568e8ff20f6ff4b13cc7ecc2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 8f4edf9bf889bbb1f7bfb5bac4d0c825d2d5374d
4+
refs/heads/snap-stage3: 7d75bbf50ddcf076d3cf294501346293060c5735
55
refs/heads/try: c274a6888410ce3e357e014568b43310ed787d36
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/doc/rust.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,9 @@ path_glob : ident [ "::" path_glob ] ?
806806

807807
A _use declaration_ creates one or more local name bindings synonymous
808808
with some other [path](#paths).
809-
Usually a `use` declaration is used to shorten the path required to refer to a module item.
809+
Usually a `use` declaration is used to shorten the path required to refer to a
810+
module item. These declarations may appear at the top of [modules](#modules) and
811+
[blocks](#blocks).
810812

811813
*Note*: Unlike in many languages,
812814
`use` declarations in Rust do *not* declare linkage dependency with external crates.
@@ -2318,14 +2320,24 @@ let base = Point3d {x: 1, y: 2, z: 3};
23182320
Point3d {y: 0, z: 10, .. base};
23192321
~~~~
23202322

2321-
### Record expressions
2323+
### Block expressions
23222324

23232325
~~~~ {.ebnf .gram}
2324-
rec_expr : '{' ident ':' expr
2325-
[ ',' ident ':' expr ] *
2326-
[ ".." expr ] '}'
2326+
block_expr : '{' [ view_item ] *
2327+
[ stmt ';' | item ] *
2328+
[ expr ] '}'
23272329
~~~~
23282330

2331+
A _block expression_ is similar to a module in terms of the declarations that
2332+
are possible. Each block conceptually introduces a new namespace scope. View
2333+
items can bring new names into scopes and declared items are in scope for only
2334+
the block itself.
2335+
2336+
A block will execute each statement sequentially, and then execute the
2337+
expression (if given). If the final expression is omitted, the type and return
2338+
value of the block are `()`, but if it is provided, the type and return value
2339+
of the block are that of the expression itself.
2340+
23292341
### Method-call expressions
23302342

23312343
~~~~ {.ebnf .gram}

branches/snap-stage3/src/compiletest/header.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,14 @@ pub fn is_test_ignored(config: &config, testfile: &Path) -> bool {
9090
fn xfail_target(config: &config) -> ~str {
9191
~"xfail-" + util::get_os(config.target)
9292
}
93+
fn xfail_stage(config: &config) -> ~str {
94+
~"xfail-" + config.stage_id.split('-').next().unwrap()
95+
}
9396
9497
let val = iter_header(testfile, |ln| {
9598
if parse_name_directive(ln, "xfail-test") { false }
9699
else if parse_name_directive(ln, xfail_target(config)) { false }
100+
else if parse_name_directive(ln, xfail_stage(config)) { false }
97101
else if config.mode == common::mode_pretty &&
98102
parse_name_directive(ln, "xfail-pretty") { false }
99103
else { true }

branches/snap-stage3/src/libextra/base64.rs

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,25 @@ impl<'a> ToBase64 for &'a [u8] {
154154
pub trait FromBase64 {
155155
/// Converts the value of `self`, interpreted as base64 encoded data, into
156156
/// an owned vector of bytes, returning the vector.
157-
fn from_base64(&self) -> Result<~[u8], ~str>;
157+
fn from_base64(&self) -> Result<~[u8], FromBase64Error>;
158+
}
159+
160+
/// Errors that can occur when decoding a base64 encoded string
161+
pub enum FromBase64Error {
162+
/// The input contained a character not part of the base64 format
163+
InvalidBase64Character(char, uint),
164+
/// The input had an invalid length
165+
InvalidBase64Length,
166+
}
167+
168+
impl ToStr for FromBase64Error {
169+
fn to_str(&self) -> ~str {
170+
match *self {
171+
InvalidBase64Character(ch, idx) =>
172+
format!("Invalid character '{}' at position {}", ch, idx),
173+
InvalidBase64Length => ~"Invalid length",
174+
}
175+
}
158176
}
159177

160178
impl<'a> FromBase64 for &'a str {
@@ -188,7 +206,7 @@ impl<'a> FromBase64 for &'a str {
188206
* }
189207
* ```
190208
*/
191-
fn from_base64(&self) -> Result<~[u8], ~str> {
209+
fn from_base64(&self) -> Result<~[u8], FromBase64Error> {
192210
let mut r = ~[];
193211
let mut buf: u32 = 0;
194212
let mut modulus = 0;
@@ -205,8 +223,7 @@ impl<'a> FromBase64 for &'a str {
205223
'/'|'_' => buf |= 0x3F,
206224
'\r'|'\n' => continue,
207225
'=' => break,
208-
_ => return Err(format!("Invalid character '{}' at position {}",
209-
self.char_at(idx), idx))
226+
_ => return Err(InvalidBase64Character(self.char_at(idx), idx)),
210227
}
211228

212229
buf <<= 6;
@@ -221,8 +238,7 @@ impl<'a> FromBase64 for &'a str {
221238

222239
for (idx, byte) in it {
223240
if (byte as char) != '=' {
224-
return Err(format!("Invalid character '{}' at position {}",
225-
self.char_at(idx), idx));
241+
return Err(InvalidBase64Character(self.char_at(idx), idx));
226242
}
227243
}
228244

@@ -235,7 +251,7 @@ impl<'a> FromBase64 for &'a str {
235251
r.push((buf >> 8 ) as u8);
236252
}
237253
0 => (),
238-
_ => return Err(~"Invalid Base64 length")
254+
_ => return Err(InvalidBase64Length),
239255
}
240256

241257
Ok(r)

branches/snap-stage3/src/libextra/comm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ mod test {
127127
// Rendezvous streams should be able to handle any number of messages being sent
128128
let (port, chan) = rendezvous();
129129
do spawn {
130-
1000000.times(|| { chan.send(()) })
130+
10000.times(|| { chan.send(()) })
131131
}
132-
1000000.times(|| { port.recv() })
132+
10000.times(|| { port.recv() })
133133
}
134134

135135
#[test]

branches/snap-stage3/src/libextra/ebml.rs

Lines changed: 79 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ pub mod reader {
9090

9191
// ebml reading
9292

93-
struct Res {
93+
pub struct Res {
9494
val: uint,
9595
next: uint
9696
}
@@ -130,32 +130,40 @@ pub mod reader {
130130
return vuint_at_slow(data, start);
131131
}
132132

133+
// Lookup table for parsing EBML Element IDs as per http://ebml.sourceforge.net/specs/
134+
// The Element IDs are parsed by reading a big endian u32 positioned at data[start].
135+
// Using the four most significant bits of the u32 we lookup in the table below how the
136+
// element ID should be derived from it.
137+
//
138+
// The table stores tuples (shift, mask) where shift is the number the u32 should be right
139+
// shifted with and mask is the value the right shifted value should be masked with.
140+
// If for example the most significant bit is set this means it's a class A ID and the u32
141+
// should be right shifted with 24 and masked with 0x7f. Therefore we store (24, 0x7f) at
142+
// index 0x8 - 0xF (four bit numbers where the most significant bit is set).
143+
//
144+
// By storing the number of shifts and masks in a table instead of checking in order if
145+
// the most significant bit is set, the second most significant bit is set etc. we can
146+
// replace up to three "and+branch" with a single table lookup which gives us a measured
147+
// speedup of around 2x on x86_64.
148+
static SHIFT_MASK_TABLE: [(u32, u32), ..16] = [
149+
(0, 0x0), (0, 0x0fffffff),
150+
(8, 0x1fffff), (8, 0x1fffff),
151+
(16, 0x3fff), (16, 0x3fff), (16, 0x3fff), (16, 0x3fff),
152+
(24, 0x7f), (24, 0x7f), (24, 0x7f), (24, 0x7f),
153+
(24, 0x7f), (24, 0x7f), (24, 0x7f), (24, 0x7f)
154+
];
155+
133156
unsafe {
134157
let (ptr, _): (*u8, uint) = transmute(data);
135158
let ptr = offset(ptr, start as int);
136159
let ptr: *i32 = transmute(ptr);
137-
let val = from_be32(*ptr);
138-
let val: u32 = transmute(val);
139-
if (val & 0x80000000) != 0 {
140-
Res {
141-
val: ((val >> 24) & 0x7f) as uint,
142-
next: start + 1
143-
}
144-
} else if (val & 0x40000000) != 0 {
145-
Res {
146-
val: ((val >> 16) & 0x3fff) as uint,
147-
next: start + 2
148-
}
149-
} else if (val & 0x20000000) != 0 {
150-
Res {
151-
val: ((val >> 8) & 0x1fffff) as uint,
152-
next: start + 3
153-
}
154-
} else {
155-
Res {
156-
val: (val & 0x0fffffff) as uint,
157-
next: start + 4
158-
}
160+
let val = from_be32(*ptr) as u32;
161+
162+
let i = (val >> 28u) as uint;
163+
let (shift, mask) = SHIFT_MASK_TABLE[i];
164+
Res {
165+
val: ((val >> shift) & mask) as uint,
166+
next: start + (((32 - shift) >> 3) as uint)
159167
}
160168
}
161169
}
@@ -938,6 +946,54 @@ mod tests {
938946
use std::io::mem::MemWriter;
939947
use std::option::{None, Option, Some};
940948

949+
#[test]
950+
fn test_vuint_at() {
951+
let data = [
952+
0x80,
953+
0xff,
954+
0x40, 0x00,
955+
0x7f, 0xff,
956+
0x20, 0x00, 0x00,
957+
0x3f, 0xff, 0xff,
958+
0x10, 0x00, 0x00, 0x00,
959+
0x1f, 0xff, 0xff, 0xff
960+
];
961+
962+
let mut res: reader::Res;
963+
964+
// Class A
965+
res = reader::vuint_at(data, 0);
966+
assert_eq!(res.val, 0);
967+
assert_eq!(res.next, 1);
968+
res = reader::vuint_at(data, res.next);
969+
assert_eq!(res.val, (1 << 7) - 1);
970+
assert_eq!(res.next, 2);
971+
972+
// Class B
973+
res = reader::vuint_at(data, res.next);
974+
assert_eq!(res.val, 0);
975+
assert_eq!(res.next, 4);
976+
res = reader::vuint_at(data, res.next);
977+
assert_eq!(res.val, (1 << 14) - 1);
978+
assert_eq!(res.next, 6);
979+
980+
// Class C
981+
res = reader::vuint_at(data, res.next);
982+
assert_eq!(res.val, 0);
983+
assert_eq!(res.next, 9);
984+
res = reader::vuint_at(data, res.next);
985+
assert_eq!(res.val, (1 << 21) - 1);
986+
assert_eq!(res.next, 12);
987+
988+
// Class D
989+
res = reader::vuint_at(data, res.next);
990+
assert_eq!(res.val, 0);
991+
assert_eq!(res.next, 16);
992+
res = reader::vuint_at(data, res.next);
993+
assert_eq!(res.val, (1 << 28) - 1);
994+
assert_eq!(res.next, 20);
995+
}
996+
941997
#[test]
942998
fn test_option_int() {
943999
fn test_v(v: Option<int>) {

branches/snap-stage3/src/libextra/hex.rs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,25 @@ impl<'a> ToHex for &'a [u8] {
5353
pub trait FromHex {
5454
/// Converts the value of `self`, interpreted as hexadecimal encoded data,
5555
/// into an owned vector of bytes, returning the vector.
56-
fn from_hex(&self) -> Result<~[u8], ~str>;
56+
fn from_hex(&self) -> Result<~[u8], FromHexError>;
57+
}
58+
59+
/// Errors that can occur when decoding a hex encoded string
60+
pub enum FromHexError {
61+
/// The input contained a character not part of the hex format
62+
InvalidHexCharacter(char, uint),
63+
/// The input had a invalid length
64+
InvalidHexLength,
65+
}
66+
67+
impl ToStr for FromHexError {
68+
fn to_str(&self) -> ~str {
69+
match *self {
70+
InvalidHexCharacter(ch, idx) =>
71+
format!("Invalid character '{}' at position {}", ch, idx),
72+
InvalidHexLength => ~"Invalid input length",
73+
}
74+
}
5775
}
5876

5977
impl<'a> FromHex for &'a str {
@@ -83,7 +101,7 @@ impl<'a> FromHex for &'a str {
83101
* }
84102
* ```
85103
*/
86-
fn from_hex(&self) -> Result<~[u8], ~str> {
104+
fn from_hex(&self) -> Result<~[u8], FromHexError> {
87105
// This may be an overestimate if there is any whitespace
88106
let mut b = vec::with_capacity(self.len() / 2);
89107
let mut modulus = 0;
@@ -100,8 +118,7 @@ impl<'a> FromHex for &'a str {
100118
buf >>= 4;
101119
continue
102120
}
103-
_ => return Err(format!("Invalid character '{}' at position {}",
104-
self.char_at(idx), idx))
121+
_ => return Err(InvalidHexCharacter(self.char_at(idx), idx)),
105122
}
106123

107124
modulus += 1;
@@ -113,7 +130,7 @@ impl<'a> FromHex for &'a str {
113130

114131
match modulus {
115132
0 => Ok(b),
116-
_ => Err(~"Invalid input length")
133+
_ => Err(InvalidHexLength),
117134
}
118135
}
119136
}

branches/snap-stage3/src/librustc/back/link.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1166,7 +1166,7 @@ fn add_local_native_libraries(args: &mut ~[~str], sess: Session) {
11661166
fn add_upstream_rust_crates(args: &mut ~[~str], sess: Session,
11671167
dylib: bool, tmpdir: &Path) {
11681168
// Converts a library file-stem into a cc -l argument
1169-
fn unlib(config: @session::config, stem: &str) -> ~str {
1169+
fn unlib(config: @session::Config, stem: &str) -> ~str {
11701170
if stem.starts_with("lib") &&
11711171
config.os != abi::OsWin32 {
11721172
stem.slice(3, stem.len()).to_owned()

branches/snap-stage3/src/librustc/back/rpath.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub fn get_rpath_flags(sess: session::Session, out_filename: &Path) -> ~[~str] {
3939

4040
debug!("preparing the RPATH!");
4141

42-
let sysroot = sess.filesearch.sysroot();
42+
let sysroot = sess.filesearch.sysroot;
4343
let output = out_filename;
4444
let libs = sess.cstore.get_used_crates(cstore::RequireDynamic);
4545
let libs = libs.move_iter().filter_map(|(_, l)| l.map(|p| p.clone())).collect();
@@ -55,7 +55,7 @@ pub fn get_rpath_flags(sess: session::Session, out_filename: &Path) -> ~[~str] {
5555

5656
fn get_sysroot_absolute_rt_lib(sess: session::Session) -> Path {
5757
let r = filesearch::relative_target_lib_path(sess.opts.target_triple);
58-
let mut p = sess.filesearch.sysroot().join(&r);
58+
let mut p = sess.filesearch.sysroot.join(&r);
5959
p.push(os::dll_filename("rustrt"));
6060
p
6161
}

0 commit comments

Comments
 (0)