mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-02 19:06:05 +00:00
parent
1dc5e1aa94
commit
50fb4c30ed
@ -308,7 +308,7 @@ fn mk_ctxt(llmod: ModuleRef) -> ctxt {
|
||||
fn add_bool(&dest: [u8], val: bool) { dest += [if val { 1u8 } else { 0u8 }]; }
|
||||
|
||||
fn add_u16(&dest: [u8], val: u16) {
|
||||
dest += [val & 0xffu16 as u8, val >> 8u16 as u8];
|
||||
dest += [(val & 0xffu16) as u8, (val >> 8u16) as u8];
|
||||
}
|
||||
|
||||
fn add_substr(&dest: [u8], src: [u8]) {
|
||||
|
@ -231,9 +231,8 @@ fn sanitize(s: str) -> str {
|
||||
|
||||
fn log_fn_time(ccx: @crate_ctxt, name: str, start: time::timeval,
|
||||
end: time::timeval) {
|
||||
let elapsed =
|
||||
1000 * (end.sec - start.sec as int) +
|
||||
((end.usec as int) - (start.usec as int)) / 1000;
|
||||
let elapsed = 1000 * ((end.sec - start.sec) as int) +
|
||||
((end.usec as int) - (start.usec as int)) / 1000;
|
||||
*ccx.stats.fn_times += [{ident: name, time: elapsed}];
|
||||
}
|
||||
|
||||
|
@ -269,9 +269,9 @@ fn eval_const_expr(e: @expr) -> const_val {
|
||||
mul { const_uint(a * b) } div { const_uint(a / b) }
|
||||
rem { const_uint(a % b) } and | bitand { const_uint(a & b) }
|
||||
or | bitor { const_uint(a | b) } bitxor { const_uint(a ^ b) }
|
||||
lsl { const_int(a << b as i64) }
|
||||
lsr { const_int(a >> b as i64) }
|
||||
asr { const_int(a >>> b as i64) }
|
||||
lsl { const_int((a << b) as i64) }
|
||||
lsr { const_int((a >> b) as i64) }
|
||||
asr { const_int((a >>> b) as i64) }
|
||||
eq { fromb(a == b) } lt { fromb(a < b) }
|
||||
le { fromb(a <= b) } ne { fromb(a != b) }
|
||||
ge { fromb(a >= b) } gt { fromb(a > b) }
|
||||
|
@ -1123,7 +1123,8 @@ type op_spec = {tok: token::token, op: ast::binop, prec: int};
|
||||
|
||||
// FIXME make this a const, don't store it in parser state
|
||||
fn prec_table() -> @[op_spec] {
|
||||
ret @[{tok: token::BINOP(token::STAR), op: ast::mul, prec: 11},
|
||||
ret @[// 'as' sits between here with 12
|
||||
{tok: token::BINOP(token::STAR), op: ast::mul, prec: 11},
|
||||
{tok: token::BINOP(token::SLASH), op: ast::div, prec: 11},
|
||||
{tok: token::BINOP(token::PERCENT), op: ast::rem, prec: 11},
|
||||
{tok: token::BINOP(token::PLUS), op: ast::add, prec: 10},
|
||||
@ -1134,7 +1135,6 @@ fn prec_table() -> @[op_spec] {
|
||||
{tok: token::BINOP(token::AND), op: ast::bitand, prec: 8},
|
||||
{tok: token::BINOP(token::CARET), op: ast::bitxor, prec: 7},
|
||||
{tok: token::BINOP(token::OR), op: ast::bitor, prec: 6},
|
||||
// 'as' sits between here with 5
|
||||
{tok: token::LT, op: ast::lt, prec: 4},
|
||||
{tok: token::LE, op: ast::le, prec: 4},
|
||||
{tok: token::GE, op: ast::ge, prec: 4},
|
||||
@ -1151,7 +1151,7 @@ fn parse_binops(p: parser) -> @ast::expr {
|
||||
|
||||
const unop_prec: int = 100;
|
||||
|
||||
const as_prec: int = 5;
|
||||
const as_prec: int = 12;
|
||||
|
||||
fn parse_more_binops(p: parser, plhs: pexpr, min_prec: int) ->
|
||||
@ast::expr {
|
||||
|
@ -119,7 +119,7 @@ mod ct {
|
||||
if i >= lim { ret none; }
|
||||
let c = s[i];
|
||||
if !('0' as u8 <= c && c <= '9' as u8) { ret option::none; }
|
||||
let n = c - ('0' as u8) as uint;
|
||||
let n = (c - ('0' as u8)) as uint;
|
||||
ret alt peek_num(s, i + 1u, lim) {
|
||||
none { some({num: n, next: i + 1u}) }
|
||||
some(next) {
|
||||
|
@ -142,25 +142,30 @@ fn push_utf8_bytes(&s: str, ch: char) {
|
||||
if code < max_one_b {
|
||||
[code as u8]
|
||||
} else if code < max_two_b {
|
||||
[code >> 6u & 31u | tag_two_b as u8, code & 63u | tag_cont as u8]
|
||||
[(code >> 6u & 31u | tag_two_b) as u8,
|
||||
(code & 63u | tag_cont) as u8]
|
||||
} else if code < max_three_b {
|
||||
[code >> 12u & 15u | tag_three_b as u8,
|
||||
code >> 6u & 63u | tag_cont as u8, code & 63u | tag_cont as u8]
|
||||
[(code >> 12u & 15u | tag_three_b) as u8,
|
||||
(code >> 6u & 63u | tag_cont) as u8,
|
||||
(code & 63u | tag_cont) as u8]
|
||||
} else if code < max_four_b {
|
||||
[code >> 18u & 7u | tag_four_b as u8,
|
||||
code >> 12u & 63u | tag_cont as u8,
|
||||
code >> 6u & 63u | tag_cont as u8, code & 63u | tag_cont as u8]
|
||||
[(code >> 18u & 7u | tag_four_b) as u8,
|
||||
(code >> 12u & 63u | tag_cont) as u8,
|
||||
(code >> 6u & 63u | tag_cont) as u8,
|
||||
(code & 63u | tag_cont) as u8]
|
||||
} else if code < max_five_b {
|
||||
[code >> 24u & 3u | tag_five_b as u8,
|
||||
code >> 18u & 63u | tag_cont as u8,
|
||||
code >> 12u & 63u | tag_cont as u8,
|
||||
code >> 6u & 63u | tag_cont as u8, code & 63u | tag_cont as u8]
|
||||
[(code >> 24u & 3u | tag_five_b) as u8,
|
||||
(code >> 18u & 63u | tag_cont) as u8,
|
||||
(code >> 12u & 63u | tag_cont) as u8,
|
||||
(code >> 6u & 63u | tag_cont) as u8,
|
||||
(code & 63u | tag_cont) as u8]
|
||||
} else {
|
||||
[code >> 30u & 1u | tag_six_b as u8,
|
||||
code >> 24u & 63u | tag_cont as u8,
|
||||
code >> 18u & 63u | tag_cont as u8,
|
||||
code >> 12u & 63u | tag_cont as u8,
|
||||
code >> 6u & 63u | tag_cont as u8, code & 63u | tag_cont as u8]
|
||||
[(code >> 30u & 1u | tag_six_b) as u8,
|
||||
(code >> 24u & 63u | tag_cont) as u8,
|
||||
(code >> 18u & 63u | tag_cont) as u8,
|
||||
(code >> 12u & 63u | tag_cont) as u8,
|
||||
(code >> 6u & 63u | tag_cont) as u8,
|
||||
(code & 63u | tag_cont) as u8]
|
||||
};
|
||||
push_bytes(s, bytes);
|
||||
}
|
||||
@ -1211,13 +1216,13 @@ fn char_range_at(s: str, i: uint) -> {ch: char, next: uint} {
|
||||
let byte = s[i];
|
||||
assert (byte & 192u8 == tag_cont_u8);
|
||||
val <<= 6u;
|
||||
val += byte & 63u8 as uint;
|
||||
val += (byte & 63u8) as uint;
|
||||
i += 1u;
|
||||
}
|
||||
// Clunky way to get the right bits from the first byte. Uses two shifts,
|
||||
// the first to clip off the marker bits at the left of the byte, and then
|
||||
// a second (as uint) to get it to the right position.
|
||||
val += (b0 << (w + 1u as u8) as uint) << ((w - 1u) * 6u - w - 1u);
|
||||
val += ((b0 << ((w + 1u) as u8)) as uint) << ((w - 1u) * 6u - w - 1u);
|
||||
ret {ch: val as char, next: i};
|
||||
}
|
||||
|
||||
|
@ -19,22 +19,22 @@ type doc = {data: @[u8], start: uint, end: uint};
|
||||
|
||||
fn vint_at(data: [u8], start: uint) -> {val: uint, next: uint} {
|
||||
let a = data[start];
|
||||
if a & 0x80u8 != 0u8 { ret {val: a & 0x7fu8 as uint, next: start + 1u}; }
|
||||
if a & 0x80u8 != 0u8 {
|
||||
ret {val: (a & 0x7fu8) as uint, next: start + 1u};
|
||||
}
|
||||
if a & 0x40u8 != 0u8 {
|
||||
ret {val: (a & 0x3fu8 as uint) << 8u | (data[start + 1u] as uint),
|
||||
ret {val: ((a & 0x3fu8) as uint) << 8u | (data[start + 1u] as uint),
|
||||
next: start + 2u};
|
||||
} else if a & 0x20u8 != 0u8 {
|
||||
ret {val:
|
||||
(a & 0x1fu8 as uint) << 16u |
|
||||
(data[start + 1u] as uint) << 8u |
|
||||
(data[start + 2u] as uint),
|
||||
ret {val: ((a & 0x1fu8) as uint) << 16u |
|
||||
(data[start + 1u] as uint) << 8u |
|
||||
(data[start + 2u] as uint),
|
||||
next: start + 3u};
|
||||
} else if a & 0x10u8 != 0u8 {
|
||||
ret {val:
|
||||
(a & 0x0fu8 as uint) << 24u |
|
||||
(data[start + 1u] as uint) << 16u |
|
||||
(data[start + 2u] as uint) << 8u |
|
||||
(data[start + 3u] as uint),
|
||||
ret {val: ((a & 0x0fu8) as uint) << 24u |
|
||||
(data[start + 1u] as uint) << 16u |
|
||||
(data[start + 2u] as uint) << 8u |
|
||||
(data[start + 3u] as uint),
|
||||
next: start + 4u};
|
||||
} else { #error("vint too big"); fail; }
|
||||
}
|
||||
@ -122,16 +122,14 @@ fn write_sized_vint(w: io::writer, n: uint, size: uint) {
|
||||
let buf: [u8];
|
||||
alt size {
|
||||
1u { buf = [0x80u8 | (n as u8)]; }
|
||||
2u { buf = [0x40u8 | (n >> 8u as u8), n & 0xffu as u8]; }
|
||||
2u { buf = [0x40u8 | ((n >> 8u) as u8), (n & 0xffu) as u8]; }
|
||||
3u {
|
||||
buf =
|
||||
[0x20u8 | (n >> 16u as u8), n >> 8u & 0xffu as u8,
|
||||
n & 0xffu as u8];
|
||||
buf = [0x20u8 | ((n >> 16u) as u8), (n >> 8u & 0xffu) as u8,
|
||||
(n & 0xffu) as u8];
|
||||
}
|
||||
4u {
|
||||
buf =
|
||||
[0x10u8 | (n >> 24u as u8), n >> 16u & 0xffu as u8,
|
||||
n >> 8u & 0xffu as u8, n & 0xffu as u8];
|
||||
buf = [0x10u8 | ((n >> 24u) as u8), (n >> 16u & 0xffu) as u8,
|
||||
(n >> 8u & 0xffu) as u8, (n & 0xffu) as u8];
|
||||
}
|
||||
_ { #error("vint to write too big"); fail; }
|
||||
}
|
||||
|
@ -70,8 +70,8 @@ fn basename(p: path) -> path unsafe {
|
||||
if i == -1 { ret p; }
|
||||
}
|
||||
let len = str::byte_len(p);
|
||||
if i + 1 as uint >= len { ret p; }
|
||||
ret str::unsafe::slice_bytes(p, i + 1 as uint, len);
|
||||
if (i + 1) as uint >= len { ret p; }
|
||||
ret str::unsafe::slice_bytes(p, (i + 1) as uint, len);
|
||||
}
|
||||
|
||||
|
||||
|
@ -59,10 +59,10 @@ impl reader_util for reader {
|
||||
assert (next > -1);
|
||||
assert (next & 192 == 128);
|
||||
val <<= 6u;
|
||||
val += next & 63 as uint;
|
||||
val += (next & 63) as uint;
|
||||
}
|
||||
// See str::char_at
|
||||
val += (b0 << (w + 1u as u8) as uint)
|
||||
val += ((b0 << ((w + 1u) as u8)) as uint)
|
||||
<< (w - 1u) * 6u - w - 1u;
|
||||
chars += [ val as char ];
|
||||
}
|
||||
@ -368,14 +368,14 @@ fn mk_file_writer(path: str, flags: [fileflag])
|
||||
|
||||
fn uint_to_le_bytes(n: uint, size: uint) -> [u8] {
|
||||
let bytes: [u8] = [], i = size, n = n;
|
||||
while i > 0u { bytes += [n & 255u as u8]; n >>= 8u; i -= 1u; }
|
||||
while i > 0u { bytes += [(n & 255u) as u8]; n >>= 8u; i -= 1u; }
|
||||
ret bytes;
|
||||
}
|
||||
|
||||
fn uint_to_be_bytes(n: uint, size: uint) -> [u8] {
|
||||
let bytes: [u8] = [];
|
||||
let i = size - 1u as int;
|
||||
while i >= 0 { bytes += [n >> (i * 8 as uint) & 255u as u8]; i -= 1; }
|
||||
let i = (size - 1u) as int;
|
||||
while i >= 0 { bytes += [(n >> ((i * 8) as uint) & 255u) as u8]; i -= 1; }
|
||||
ret bytes;
|
||||
}
|
||||
|
||||
|
@ -296,7 +296,7 @@ mod chained {
|
||||
|
||||
fn insert(k: K, v: V) -> bool {
|
||||
let nchains = vec::len(self.chains);
|
||||
let load = {num: self.size + 1u as int, den: nchains as int};
|
||||
let load = {num: (self.size + 1u) as int, den: nchains as int};
|
||||
// Structural consts would be nice. This is a const 3/4
|
||||
// load factor that we compare against.
|
||||
if !util::rational_leq(load, {num:3, den:4}) { rehash(self); }
|
||||
|
@ -193,10 +193,10 @@ fn mk_sha1() -> sha1 {
|
||||
if !st.computed { pad_msg(st); st.computed = true; }
|
||||
let rs: [u8] = [];
|
||||
for hpart: u32 in st.h {
|
||||
let a = hpart >> 24u32 & 0xFFu32 as u8;
|
||||
let b = hpart >> 16u32 & 0xFFu32 as u8;
|
||||
let c = hpart >> 8u32 & 0xFFu32 as u8;
|
||||
let d = hpart & 0xFFu32 as u8;
|
||||
let a = (hpart >> 24u32 & 0xFFu32) as u8;
|
||||
let b = (hpart >> 16u32 & 0xFFu32) as u8;
|
||||
let c = (hpart >> 8u32 & 0xFFu32) as u8;
|
||||
let d = (hpart & 0xFFu32) as u8;
|
||||
rs += [a, b, c, d];
|
||||
}
|
||||
ret rs;
|
||||
@ -238,14 +238,14 @@ fn mk_sha1() -> sha1 {
|
||||
}
|
||||
|
||||
// Store the message length as the last 8 octets
|
||||
st.msg_block[56] = st.len_high >> 24u32 & 0xFFu32 as u8;
|
||||
st.msg_block[57] = st.len_high >> 16u32 & 0xFFu32 as u8;
|
||||
st.msg_block[58] = st.len_high >> 8u32 & 0xFFu32 as u8;
|
||||
st.msg_block[59] = st.len_high & 0xFFu32 as u8;
|
||||
st.msg_block[60] = st.len_low >> 24u32 & 0xFFu32 as u8;
|
||||
st.msg_block[61] = st.len_low >> 16u32 & 0xFFu32 as u8;
|
||||
st.msg_block[62] = st.len_low >> 8u32 & 0xFFu32 as u8;
|
||||
st.msg_block[63] = st.len_low & 0xFFu32 as u8;
|
||||
st.msg_block[56] = (st.len_high >> 24u32 & 0xFFu32) as u8;
|
||||
st.msg_block[57] = (st.len_high >> 16u32 & 0xFFu32) as u8;
|
||||
st.msg_block[58] = (st.len_high >> 8u32 & 0xFFu32) as u8;
|
||||
st.msg_block[59] = (st.len_high & 0xFFu32) as u8;
|
||||
st.msg_block[60] = (st.len_low >> 24u32 & 0xFFu32) as u8;
|
||||
st.msg_block[61] = (st.len_low >> 16u32 & 0xFFu32) as u8;
|
||||
st.msg_block[62] = (st.len_low >> 8u32 & 0xFFu32) as u8;
|
||||
st.msg_block[63] = (st.len_low & 0xFFu32) as u8;
|
||||
process_msg_block(st);
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ fn run(args: [str]) {
|
||||
let elapsed = end - start;
|
||||
std::io::stdout().write_str(#fmt("Count is %?\n", result));
|
||||
std::io::stdout().write_str(#fmt("Test took %? seconds\n", elapsed));
|
||||
let thruput = (size / workers * workers as float) / (elapsed as float);
|
||||
let thruput = ((size / workers * workers) as float) / (elapsed as float);
|
||||
std::io::stdout().write_str(#fmt("Throughput=%f per sec\n", thruput));
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ fn main(args: [str]) {
|
||||
let long_lived_tree = bottom_up_tree(0, max_depth);
|
||||
let depth = min_depth;
|
||||
while depth <= max_depth {
|
||||
let iterations = int::pow(2, max_depth - depth + min_depth as uint);
|
||||
let iterations = int::pow(2, (max_depth - depth + min_depth) as uint);
|
||||
let chk = 0;
|
||||
let i = 1;
|
||||
while i <= iterations {
|
||||
|
@ -5,7 +5,7 @@ enum t3 { c(t2, uint), }
|
||||
fn m(in: t3) -> int {
|
||||
alt in {
|
||||
c({x: a(m), _}, _) { ret m; }
|
||||
c({x: b(m), y: y}, z) { ret (m + z as int) + y; }
|
||||
c({x: b(m), y: y}, z) { ret ((m + z) as int) + y; }
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user