diff options
| author | Patrick Walton <[email protected]> | 2011-03-31 14:37:09 -0700 |
|---|---|---|
| committer | Patrick Walton <[email protected]> | 2011-03-31 14:37:44 -0700 |
| commit | 3c1de96cda33e9547adda14dc66294752c99e4c3 (patch) | |
| tree | 63d8743667358697013299ba452f412f48c658f2 /src/lib/io.rs | |
| parent | More stuff to go with the new expr_call_self AST node (diff) | |
| download | rust-3c1de96cda33e9547adda14dc66294752c99e4c3.tar.xz rust-3c1de96cda33e9547adda14dc66294752c99e4c3.zip | |
rustc: Use the crate index to look up defs
Diffstat (limited to 'src/lib/io.rs')
| -rw-r--r-- | src/lib/io.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/lib/io.rs b/src/lib/io.rs index 11e6408c..7c6c0970 100644 --- a/src/lib/io.rs +++ b/src/lib/io.rs @@ -39,6 +39,7 @@ type reader = impure fn read_c_str() -> str; impure fn read_le_uint(uint size) -> uint; impure fn read_le_int(uint size) -> int; + impure fn read_be_uint(uint size) -> uint; impure fn seek(int offset, seek_style whence); impure fn tell() -> uint; // FIXME: eventually u64 @@ -167,6 +168,16 @@ state obj new_reader(buf_reader rdr) { } ret val as int; } + // FIXME deal with eof? + impure fn read_be_uint(uint size) -> uint { + auto val = 0u; + auto sz = size; // FIXME: trans.ml bug workaround + while (sz > 0u) { + sz -= 1u; + val += (read_byte_from_buf_reader(rdr) as uint) << (sz * 8u); + } + ret val; + } impure fn seek(int offset, seek_style whence) { ret rdr.seek(offset, whence); } |