aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorMarijn Haverbeke <[email protected]>2011-05-12 17:24:54 +0200
committerMarijn Haverbeke <[email protected]>2011-05-12 21:30:44 +0200
commit3816e57fd2a8ab19e4ac6d4b3ddd5b49d5973ff2 (patch)
tree508982ed2f789aedd89eebd529343d9dc88b8e01 /src/lib
parentTransitional change to make extfmt output lowercase module name (diff)
downloadrust-3816e57fd2a8ab19e4ac6d4b3ddd5b49d5973ff2.tar.xz
rust-3816e57fd2a8ab19e4ac6d4b3ddd5b49d5973ff2.zip
Downcase std modules again, move to :: for module dereferencing
This should be a snapshot transition.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/GenericOS.rs9
-rw-r--r--src/lib/_int.rs (renamed from src/lib/Int.rs)4
-rw-r--r--src/lib/_str.rs (renamed from src/lib/Str.rs)82
-rw-r--r--src/lib/_task.rs (renamed from src/lib/Task.rs)2
-rw-r--r--src/lib/_u8.rs (renamed from src/lib/U8.rs)0
-rw-r--r--src/lib/_uint.rs (renamed from src/lib/UInt.rs)12
-rw-r--r--src/lib/_vec.rs (renamed from src/lib/Vec.rs)44
-rw-r--r--src/lib/bitv.rs (renamed from src/lib/BitV.rs)26
-rw-r--r--src/lib/box.rs (renamed from src/lib/Box.rs)2
-rw-r--r--src/lib/dbg.rs (renamed from src/lib/Dbg.rs)18
-rw-r--r--src/lib/deque.rs (renamed from src/lib/Deque.rs)36
-rw-r--r--src/lib/ebml.rs (renamed from src/lib/EBML.rs)36
-rw-r--r--src/lib/extfmt.rs (renamed from src/lib/ExtFmt.rs)80
-rw-r--r--src/lib/fs.rs (renamed from src/lib/FS.rs)24
-rw-r--r--src/lib/generic_os.rs9
-rw-r--r--src/lib/getopts.rs (renamed from src/lib/GetOpts.rs)82
-rw-r--r--src/lib/io.rs (renamed from src/lib/IO.rs)124
-rw-r--r--src/lib/linux_os.rs (renamed from src/lib/linux_OS.rs)14
-rw-r--r--src/lib/list.rs (renamed from src/lib/List.rs)6
-rw-r--r--src/lib/macos_os.rs (renamed from src/lib/macos_OS.rs)14
-rw-r--r--src/lib/map.rs (renamed from src/lib/Map.rs)38
-rw-r--r--src/lib/option.rs (renamed from src/lib/Option.rs)4
-rw-r--r--src/lib/posix_fs.rs (renamed from src/lib/posix_FS.rs)12
-rw-r--r--src/lib/rand.rs (renamed from src/lib/Rand.rs)8
-rw-r--r--src/lib/run_program.rs (renamed from src/lib/Run_Program.rs)56
-rw-r--r--src/lib/sha1.rs (renamed from src/lib/SHA1.rs)18
-rw-r--r--src/lib/sort.rs (renamed from src/lib/Sort.rs)4
-rw-r--r--src/lib/std.rc96
-rw-r--r--src/lib/sys.rs (renamed from src/lib/Sys.rs)0
-rw-r--r--src/lib/term.rs (renamed from src/lib/Term.rs)12
-rw-r--r--src/lib/time.rs (renamed from src/lib/Time.rs)2
-rw-r--r--src/lib/ufind.rs (renamed from src/lib/UFind.rs)10
-rw-r--r--src/lib/util.rs (renamed from src/lib/Util.rs)4
-rw-r--r--src/lib/win32_fs.rs (renamed from src/lib/win32_FS.rs)2
-rw-r--r--src/lib/win32_os.rs (renamed from src/lib/win32_OS.rs)14
35 files changed, 452 insertions, 452 deletions
diff --git a/src/lib/GenericOS.rs b/src/lib/GenericOS.rs
deleted file mode 100644
index 567843f2..00000000
--- a/src/lib/GenericOS.rs
+++ /dev/null
@@ -1,9 +0,0 @@
-fn getenv(str n) -> Option.t[str] {
- auto s = OS.libc.getenv(Str.buf(n));
- if ((s as int) == 0) {
- ret Option.none[str];
- } else {
- ret Option.some[str](Str.str_from_cstr(s));
- }
-}
-
diff --git a/src/lib/Int.rs b/src/lib/_int.rs
index 59fb507f..321602ec 100644
--- a/src/lib/Int.rs
+++ b/src/lib/_int.rs
@@ -29,9 +29,9 @@ fn to_str(int n, uint radix) -> str
{
assert (0u < radix && radix <= 16u);
if (n < 0) {
- ret "-" + UInt.to_str((-n) as uint, radix);
+ ret "-" + _uint::to_str((-n) as uint, radix);
} else {
- ret UInt.to_str(n as uint, radix);
+ ret _uint::to_str(n as uint, radix);
}
}
diff --git a/src/lib/Str.rs b/src/lib/_str.rs
index 6e39b359..36b2376d 100644
--- a/src/lib/Str.rs
+++ b/src/lib/_str.rs
@@ -1,6 +1,6 @@
-import rustrt.sbuf;
+import rustrt::sbuf;
-import Vec.rustrt.vbuf;
+import _vec::rustrt::vbuf;
native "rust" mod rustrt {
type sbuf;
@@ -84,7 +84,7 @@ const uint tag_six_b = 0xfc_u;
fn is_utf8(vec[u8] v) -> bool {
auto i = 0u;
- auto total = Vec.len[u8](v);
+ auto total = _vec::len[u8](v);
while (i < total) {
auto chsize = utf8_char_width(v.(i));
if (chsize == 0u) {ret false;}
@@ -111,7 +111,7 @@ fn is_ascii(str s) -> bool {
}
fn alloc(uint n_bytes) -> str {
- ret rustrt.str_alloc(n_bytes);
+ ret rustrt::str_alloc(n_bytes);
}
// Returns the number of bytes (a.k.a. UTF-8 code units) in s.
@@ -120,67 +120,67 @@ fn alloc(uint n_bytes) -> str {
// http://icu-project.org/apiref/icu4c/classBreakIterator.html for a
// way to implement those.
fn byte_len(str s) -> uint {
- ret rustrt.str_byte_len(s);
+ ret rustrt::str_byte_len(s);
}
fn buf(str s) -> sbuf {
- ret rustrt.str_buf(s);
+ ret rustrt::str_buf(s);
}
fn bytes(str s) -> vec[u8] {
- ret rustrt.str_vec(s);
+ ret rustrt::str_vec(s);
}
fn from_bytes(vec[u8] v) : is_utf8(v) -> str {
- ret rustrt.str_from_vec(v);
+ ret rustrt::str_from_vec(v);
}
// FIXME temp thing
fn unsafe_from_bytes(vec[mutable? u8] v) -> str {
- ret rustrt.str_from_vec(v);
+ ret rustrt::str_from_vec(v);
}
fn unsafe_from_byte(u8 u) -> str {
- ret rustrt.str_from_vec(vec(u));
+ ret rustrt::str_from_vec(vec(u));
}
fn str_from_cstr(sbuf cstr) -> str {
- ret rustrt.str_from_cstr(cstr);
+ ret rustrt::str_from_cstr(cstr);
}
fn str_from_buf(sbuf buf, uint len) -> str {
- ret rustrt.str_from_buf(buf, len);
+ ret rustrt::str_from_buf(buf, len);
}
fn push_utf8_bytes(&mutable str s, char ch) {
auto code = ch as uint;
if (code < max_one_b) {
- s = rustrt.str_push_byte(s, code);
+ s = rustrt::str_push_byte(s, code);
} else if (code < max_two_b) {
- s = rustrt.str_push_byte(s, ((code >> 6u) & 0x1f_u) | tag_two_b);
- s = rustrt.str_push_byte(s, (code & 0x3f_u) | tag_cont);
+ s = rustrt::str_push_byte(s, ((code >> 6u) & 0x1f_u) | tag_two_b);
+ s = rustrt::str_push_byte(s, (code & 0x3f_u) | tag_cont);
} else if (code < max_three_b) {
- s = rustrt.str_push_byte(s, ((code >> 12u) & 0x0f_u) | tag_three_b);
- s = rustrt.str_push_byte(s, ((code >> 6u) & 0x3f_u) | tag_cont);
- s = rustrt.str_push_byte(s, (code & 0x3f_u) | tag_cont);
+ s = rustrt::str_push_byte(s, ((code >> 12u) & 0x0f_u) | tag_three_b);
+ s = rustrt::str_push_byte(s, ((code >> 6u) & 0x3f_u) | tag_cont);
+ s = rustrt::str_push_byte(s, (code & 0x3f_u) | tag_cont);
} else if (code < max_four_b) {
- s = rustrt.str_push_byte(s, ((code >> 18u) & 0x07_u) | tag_four_b);
- s = rustrt.str_push_byte(s, ((code >> 12u) & 0x3f_u) | tag_cont);
- s = rustrt.str_push_byte(s, ((code >> 6u) & 0x3f_u) | tag_cont);
- s = rustrt.str_push_byte(s, (code & 0x3f_u) | tag_cont);
+ s = rustrt::str_push_byte(s, ((code >> 18u) & 0x07_u) | tag_four_b);
+ s = rustrt::str_push_byte(s, ((code >> 12u) & 0x3f_u) | tag_cont);
+ s = rustrt::str_push_byte(s, ((code >> 6u) & 0x3f_u) | tag_cont);
+ s = rustrt::str_push_byte(s, (code & 0x3f_u) | tag_cont);
} else if (code < max_five_b) {
- s = rustrt.str_push_byte(s, ((code >> 24u) & 0x03_u) | tag_five_b);
- s = rustrt.str_push_byte(s, ((code >> 18u) & 0x3f_u) | tag_cont);
- s = rustrt.str_push_byte(s, ((code >> 12u) & 0x3f_u) | tag_cont);
- s = rustrt.str_push_byte(s, ((code >> 6u) & 0x3f_u) | tag_cont);
- s = rustrt.str_push_byte(s, (code & 0x3f_u) | tag_cont);
+ s = rustrt::str_push_byte(s, ((code >> 24u) & 0x03_u) | tag_five_b);
+ s = rustrt::str_push_byte(s, ((code >> 18u) & 0x3f_u) | tag_cont);
+ s = rustrt::str_push_byte(s, ((code >> 12u) & 0x3f_u) | tag_cont);
+ s = rustrt::str_push_byte(s, ((code >> 6u) & 0x3f_u) | tag_cont);
+ s = rustrt::str_push_byte(s, (code & 0x3f_u) | tag_cont);
} else {
- s = rustrt.str_push_byte(s, ((code >> 30u) & 0x01_u) | tag_six_b);
- s = rustrt.str_push_byte(s, ((code >> 24u) & 0x3f_u) | tag_cont);
- s = rustrt.str_push_byte(s, ((code >> 18u) & 0x3f_u) | tag_cont);
- s = rustrt.str_push_byte(s, ((code >> 12u) & 0x3f_u) | tag_cont);
- s = rustrt.str_push_byte(s, ((code >> 6u) & 0x3f_u) | tag_cont);
- s = rustrt.str_push_byte(s, (code & 0x3f_u) | tag_cont);
+ s = rustrt::str_push_byte(s, ((code >> 30u) & 0x01_u) | tag_six_b);
+ s = rustrt::str_push_byte(s, ((code >> 24u) & 0x3f_u) | tag_cont);
+ s = rustrt::str_push_byte(s, ((code >> 18u) & 0x3f_u) | tag_cont);
+ s = rustrt::str_push_byte(s, ((code >> 12u) & 0x3f_u) | tag_cont);
+ s = rustrt::str_push_byte(s, ((code >> 6u) & 0x3f_u) | tag_cont);
+ s = rustrt::str_push_byte(s, (code & 0x3f_u) | tag_cont);
}
}
@@ -253,7 +253,7 @@ fn to_chars(str s) -> vec[char] {
auto len = byte_len(s);
while (i < len) {
auto cur = char_range_at(s, i);
- Vec.push[char](buf, cur._0);
+ _vec::push[char](buf, cur._0);
i = cur._1;
}
ret buf;
@@ -287,8 +287,8 @@ fn unshift_char(&mutable str s, char ch) {
}
fn refcount(str s) -> uint {
- auto r = rustrt.refcount[u8](s);
- if (r == Dbg.const_refcount) {
+ auto r = rustrt::refcount[u8](s);
+ if (r == dbg::const_refcount) {
ret r;
} else {
// -1 because calling this function incremented the refcount.
@@ -311,7 +311,7 @@ fn index(str s, u8 c) -> int {
}
fn rindex(str s, u8 c) -> int {
- let int n = Str.byte_len(s) as int;
+ let int n = _str::byte_len(s) as int;
while (n >= 0) {
if (s.(n) == c) {
ret n;
@@ -387,8 +387,8 @@ fn substr(str s, uint begin, uint len) -> str {
fn slice(str s, uint begin, uint end) -> str {
// FIXME: Typestate precondition
assert (begin <= end);
- assert (end <= Str.byte_len(s));
- ret rustrt.str_slice(s, begin, end);
+ assert (end <= _str::byte_len(s));
+ ret rustrt::str_slice(s, begin, end);
}
fn shift_byte(&mutable str s) -> u8 {
@@ -408,7 +408,7 @@ fn pop_byte(&mutable str s) -> u8 {
}
fn push_byte(&mutable str s, u8 b) {
- s = rustrt.str_push_byte(s, b as uint);
+ s = rustrt::str_push_byte(s, b as uint);
}
fn unshift_byte(&mutable str s, u8 b) {
@@ -432,7 +432,7 @@ fn split(str s, u8 sep) -> vec[str] {
ends_with_sep = false;
}
}
- if (Str.byte_len(accum) != 0u ||
+ if (_str::byte_len(accum) != 0u ||
ends_with_sep) {
v += vec(accum);
}
diff --git a/src/lib/Task.rs b/src/lib/_task.rs
index 8eece16b..b6b754f0 100644
--- a/src/lib/Task.rs
+++ b/src/lib/_task.rs
@@ -8,7 +8,7 @@ native "rust" mod rustrt {
* arg: time_in_us maximum number of microseconds to yield control for
*/
fn sleep(uint time_in_us) {
- ret rustrt.task_sleep(time_in_us);
+ ret rustrt::task_sleep(time_in_us);
}
// Local Variables:
diff --git a/src/lib/U8.rs b/src/lib/_u8.rs
index e094e581..e094e581 100644
--- a/src/lib/U8.rs
+++ b/src/lib/_u8.rs
diff --git a/src/lib/UInt.rs b/src/lib/_uint.rs
index eea52325..a68901cc 100644
--- a/src/lib/UInt.rs
+++ b/src/lib/_uint.rs
@@ -23,7 +23,7 @@ iter range(uint lo, uint hi) -> uint {
fn next_power_of_two(uint n) -> uint {
// FIXME change |* uint(4)| below to |* uint(8) / uint(2)| and watch the
// world explode.
- let uint halfbits = Sys.rustrt.size_of[uint]() * 4u;
+ let uint halfbits = sys::rustrt::size_of[uint]() * 4u;
let uint tmp = n - 1u;
let uint shift = 1u;
while (shift <= halfbits) {
@@ -34,12 +34,12 @@ fn next_power_of_two(uint n) -> uint {
}
fn parse_buf(vec[u8] buf, uint radix) -> uint {
- if (Vec.len[u8](buf) == 0u) {
+ if (_vec::len[u8](buf) == 0u) {
log_err "parse_buf(): buf is empty";
fail;
}
- auto i = Vec.len[u8](buf) - 1u;
+ auto i = _vec::len[u8](buf) - 1u;
auto power = 1u;
auto n = 0u;
while (true) {
@@ -83,15 +83,15 @@ fn to_str(uint num, uint radix) -> str
let str s = "";
while (n != 0u) {
- s += Str.unsafe_from_byte(digit(n % radix) as u8);
+ s += _str::unsafe_from_byte(digit(n % radix) as u8);
n /= radix;
}
let str s1 = "";
- let uint len = Str.byte_len(s);
+ let uint len = _str::byte_len(s);
while (len != 0u) {
len -= 1u;
- s1 += Str.unsafe_from_byte(s.(len));
+ s1 += _str::unsafe_from_byte(s.(len));
}
ret s1;
diff --git a/src/lib/Vec.rs b/src/lib/_vec.rs
index 28b5d018..0988864a 100644
--- a/src/lib/Vec.rs
+++ b/src/lib/_vec.rs
@@ -1,8 +1,8 @@
-import Option.none;
-import Option.some;
-import Util.orb;
+import option::none;
+import option::some;
+import util::orb;
-type vbuf = rustrt.vbuf;
+type vbuf = rustrt::vbuf;
type operator2[T,U,V] = fn(&T, &U) -> V;
@@ -38,16 +38,16 @@ native "rust" mod rustrt {
}
fn alloc[T](uint n_elts) -> vec[T] {
- ret rustrt.vec_alloc[vec[T], T](n_elts);
+ ret rustrt::vec_alloc[vec[T], T](n_elts);
}
fn alloc_mut[T](uint n_elts) -> vec[mutable T] {
- ret rustrt.vec_alloc_mut[vec[mutable T], T](n_elts);
+ ret rustrt::vec_alloc_mut[vec[mutable T], T](n_elts);
}
fn refcount[T](array[T] v) -> uint {
- auto r = rustrt.refcount[T](v);
- if (r == Dbg.const_refcount) {
+ auto r = rustrt::refcount[T](v);
+ if (r == dbg::const_refcount) {
ret r;
} else {
// -1 because calling this function incremented the refcount.
@@ -56,7 +56,7 @@ fn refcount[T](array[T] v) -> uint {
}
fn vec_from_vbuf[T](vbuf v, uint n_elts) -> vec[T] {
- ret rustrt.vec_from_vbuf[T](v, n_elts);
+ ret rustrt::vec_from_vbuf[T](v, n_elts);
}
// FIXME: Remove me; this is a botch to get around rustboot's bad typechecker.
@@ -119,28 +119,28 @@ fn init_elt_mut[T](&T t, uint n_elts) -> vec[mutable T] {
}
fn buf[T](array[T] v) -> vbuf {
- ret rustrt.vec_buf[T](v, 0u);
+ ret rustrt::vec_buf[T](v, 0u);
}
fn len[T](array[T] v) -> uint {
- ret rustrt.vec_len[T](v);
+ ret rustrt::vec_len[T](v);
}
fn len_set[T](array[T] v, uint n) {
- rustrt.vec_len_set[T](v, n);
+ rustrt::vec_len_set[T](v, n);
}
fn buf_off[T](array[T] v, uint offset) -> vbuf {
assert (offset < len[T](v));
- ret rustrt.vec_buf[T](v, offset);
+ ret rustrt::vec_buf[T](v, offset);
}
fn print_debug_info[T](array[T] v) {
- rustrt.vec_print_debug_info[T](v);
+ rustrt::vec_print_debug_info[T](v);
}
// Returns the last element of v.
-fn last[T](array[T] v) -> Option.t[T] {
+fn last[T](array[T] v) -> option::t[T] {
auto l = len[T](v);
if (l == 0u) {
ret none[T];
@@ -199,14 +199,14 @@ fn grow[T](&array[T] v, uint n, &T initval) {
}
fn grow_set[T](&vec[mutable T] v, uint index, &T initval, &T val) {
- auto length = Vec.len(v);
+ auto length = _vec::len(v);
if (index >= length) {
grow(v, index - length + 1u, initval);
}
v.(index) = val;
}
-fn map[T, U](&Option.operator[T,U] f, &array[T] v) -> vec[U] {
+fn map[T, U](&option::operator[T,U] f, &array[T] v) -> vec[U] {
let vec[U] u = alloc[U](len[T](v));
for (T ve in v) {
u += vec(f(ve));
@@ -230,7 +230,7 @@ fn map2[T,U,V](&operator2[T,U,V] f, &array[T] v0, &array[U] v1) -> vec[V] {
ret u;
}
-fn find[T](fn (&T) -> bool f, &array[T] v) -> Option.t[T] {
+fn find[T](fn (&T) -> bool f, &array[T] v) -> option::t[T] {
for (T elt in v) {
if (f(elt)) {
ret some[T](elt);
@@ -270,24 +270,24 @@ fn unzip[T, U](&vec[tup(T, U)] v) -> tup(vec[T], vec[U]) {
fn or(&vec[bool] v) -> bool {
auto f = orb;
- ret Vec.foldl[bool, bool](f, false, v);
+ ret _vec::foldl[bool, bool](f, false, v);
}
fn clone[T](&vec[T] v) -> vec[T] {
ret slice[T](v, 0u, len[T](v));
}
-fn plus_option[T](&vec[T] v, &Option.t[T] o) -> () {
+fn plus_option[T](&vec[T] v, &option::t[T] o) -> () {
alt (o) {
case (none[T]) {}
case (some[T](?x)) { v += vec(x); }
}
}
-fn cat_options[T](&vec[Option.t[T]] v) -> vec[T] {
+fn cat_options[T](&vec[option::t[T]] v) -> vec[T] {
let vec[T] res = vec();
- for (Option.t[T] o in v) {
+ for (option::t[T] o in v) {
alt (o) {
case (none[T]) { }
case (some[T](?t)) {
diff --git a/src/lib/BitV.rs b/src/lib/bitv.rs
index b0a4c9ea..1b4528a4 100644
--- a/src/lib/BitV.rs
+++ b/src/lib/bitv.rs
@@ -21,19 +21,19 @@ fn create(uint nbits, bool init) -> t {
elt = 0u;
}
- auto storage = Vec.init_elt_mut[uint](elt, nbits / uint_bits() + 1u);
+ auto storage = _vec::init_elt_mut[uint](elt, nbits / uint_bits() + 1u);
ret rec(storage = storage, nbits = nbits);
}
fn process(&fn(uint, uint) -> uint op, &t v0, &t v1) -> bool {
- auto len = Vec.len(v1.storage);
+ auto len = _vec::len(v1.storage);
- assert (Vec.len(v0.storage) == len);
+ assert (_vec::len(v0.storage) == len);
assert (v0.nbits == v1.nbits);
auto changed = false;
- for each (uint i in UInt.range(0u, len)) {
+ for each (uint i in _uint::range(0u, len)) {
auto w0 = v0.storage.(i);
auto w1 = v1.storage.(i);
@@ -75,9 +75,9 @@ fn copy(&t v0, t v1) -> bool {
}
fn clone(t v) -> t {
- auto storage = Vec.init_elt_mut[uint](0u, v.nbits / uint_bits() + 1u);
- auto len = Vec.len(v.storage);
- for each (uint i in UInt.range(0u, len)) {
+ auto storage = _vec::init_elt_mut[uint](0u, v.nbits / uint_bits() + 1u);
+ auto len = _vec::len(v.storage);
+ for each (uint i in _uint::range(0u, len)) {
storage.(i) = v.storage.(i);
}
ret rec(storage = storage, nbits = v.nbits);
@@ -97,7 +97,7 @@ fn get(&t v, uint i) -> bool {
fn equal(&t v0, &t v1) -> bool {
// FIXME: when we can break or return from inside an iterator loop,
// we can eliminate this painful while-loop
- auto len = Vec.len(v1.storage);
+ auto len = _vec::len(v1.storage);
auto i = 0u;
while (i < len) {
if (v0.storage.(i) != v1.storage.(i)) {
@@ -109,13 +109,13 @@ fn equal(&t v0, &t v1) -> bool {
}
fn clear(&t v) {
- for each (uint i in UInt.range(0u, Vec.len(v.storage))) {
+ for each (uint i in _uint::range(0u, _vec::len(v.storage))) {
v.storage.(i) = 0u;
}
}
fn invert(&t v) {
- for each (uint i in UInt.range(0u, Vec.len(v.storage))) {
+ for each (uint i in _uint::range(0u, _vec::len(v.storage))) {
v.storage.(i) = ~v.storage.(i);
}
}
@@ -176,13 +176,13 @@ fn init_to_vec(t v, uint i) -> uint {
fn to_vec(&t v) -> vec[uint] {
auto sub = bind init_to_vec(v, _);
- ret Vec.init_fn[uint](sub, v.nbits);
+ ret _vec::init_fn[uint](sub, v.nbits);
}
fn to_str(&t v) -> str {
auto res = "";
- for (uint i in BitV.to_vec(v)) {
+ for (uint i in bitv::to_vec(v)) {
if (i == 1u) {
res += "1";
}
@@ -196,7 +196,7 @@ fn to_str(&t v) -> str {
// FIXME: can we just use structural equality on to_vec?
fn eq_vec(&t v0, &vec[uint] v1) -> bool {
- assert (v0.nbits == Vec.len[uint](v1));
+ assert (v0.nbits == _vec::len[uint](v1));
auto len = v0.nbits;
auto i = 0u;
while (i < len) {
diff --git a/src/lib/Box.rs b/src/lib/box.rs
index 2d94c680..4429fd6a 100644
--- a/src/lib/Box.rs
+++ b/src/lib/box.rs
@@ -4,5 +4,5 @@ native "rust" mod rustrt {
fn rust_ptr_eq[T](@T a, @T b) -> int;
}
-fn ptr_eq[T](@T a, @T b) -> bool { ret rustrt.rust_ptr_eq[T](a, b) != 0; }
+fn ptr_eq[T](@T a, @T b) -> bool { ret rustrt::rust_ptr_eq[T](a, b) != 0; }
diff --git a/src/lib/Dbg.rs b/src/lib/dbg.rs
index f155d119..be367562 100644
--- a/src/lib/Dbg.rs
+++ b/src/lib/dbg.rs
@@ -20,23 +20,23 @@ native "rust" mod rustrt {
}
fn debug_vec[T](vec[T] v) {
- Vec.print_debug_info[T](v);
+ _vec::print_debug_info[T](v);
}
fn debug_tydesc[T]() {
- rustrt.debug_tydesc[T]();
+ rustrt::debug_tydesc[T]();
}
fn debug_opaque[T](&T x) {
- rustrt.debug_opaque[T](x);
+ rustrt::debug_opaque[T](x);
}
fn debug_box[T](@T x) {
- rustrt.debug_box[T](x);
+ rustrt::debug_box[T](x);
}
fn debug_tag[T](&T x) {
- rustrt.debug_tag[T](x);
+ rustrt::debug_tag[T](x);
}
/**
@@ -49,19 +49,19 @@ fn debug_tag[T](&T x) {
* the front of any obj's data tuple.x
*/
fn debug_obj[T](&T x, uint nmethods, uint nbytes) {
- rustrt.debug_obj[T](x, nmethods, nbytes);
+ rustrt::debug_obj[T](x, nmethods, nbytes);
}
fn debug_fn[T](&T x) {
- rustrt.debug_fn[T](x);
+ rustrt::debug_fn[T](x);
}
fn ptr_cast[T, U](@T x) -> @U {
- ret rustrt.debug_ptrcast[T, U](x);
+ ret rustrt::debug_ptrcast[T, U](x);
}
fn trap(str s) {
- rustrt.debug_trap(s);
+ rustrt::debug_trap(s);
}
// Local Variables:
diff --git a/src/lib/Deque.rs b/src/lib/deque.rs
index a38e4fec..c0ded5bf 100644
--- a/src/lib/Deque.rs
+++ b/src/lib/deque.rs
@@ -19,7 +19,7 @@ type t[T] = obj {
fn create[T]() -> t[T] {
- type cell[T] = Option.t[T];
+ type cell[T] = option::t[T];
let uint initial_capacity = 32u; // 2^5
@@ -28,25 +28,25 @@ fn create[T]() -> t[T] {
* elsewhere.
*/
fn grow[T](uint nelts, uint lo, vec[cell[T]] elts) -> vec[cell[T]] {
- assert (nelts == Vec.len[cell[T]](elts));
+ assert (nelts == _vec::len[cell[T]](elts));
fn fill[T](uint i, uint nelts, uint lo,
vec[cell[T]] old) -> cell[T] {
if (i < nelts) {
ret old.((lo + i) % nelts);
} else {
- ret Option.none[T];
+ ret option::none[T];
}
}
- let uint nalloc = UInt.next_power_of_two(nelts + 1u);
- let Vec.init_op[cell[T]] copy_op = bind fill[T](_, nelts, lo, elts);
- ret Vec.init_fn[cell[T]](copy_op, nalloc);
+ let uint nalloc = _uint::next_power_of_two(nelts + 1u);
+ let _vec::init_op[cell[T]] copy_op = bind fill[T](_, nelts, lo, elts);
+ ret _vec::init_fn[cell[T]](copy_op, nalloc);
}
fn get[T](vec[cell[T]] elts, uint i) -> T {
alt (elts.(i)) {
- case (Option.some[T](?t)) { ret t; }
+ case (option::some[T](?t)) { ret t; }
case (_) { fail; }
}
fail; // FIXME: remove me when exhaustiveness checking works
@@ -63,18 +63,18 @@ fn create[T]() -> t[T] {
let uint oldlo = lo;
if (lo == 0u) {
- lo = Vec.len[cell[T]](elts) - 1u;
+ lo = _vec::len[cell[T]](elts) - 1u;
} else {
lo -= 1u;
}
if (lo == hi) {
elts = grow[T](nelts, oldlo, elts);
- lo = Vec.len[cell[T]](elts) - 1u;
+ lo = _vec::len[cell[T]](elts) - 1u;
hi = nelts;
}
- elts.(lo) = Option.some[T](t);
+ elts.(lo) = option::some[T](t);
nelts += 1u;
}
@@ -85,8 +85,8 @@ fn create[T]() -> t[T] {
hi = nelts;
}
- elts.(hi) = Option.some[T](t);
- hi = (hi + 1u) % Vec.len[cell[T]](elts);
+ elts.(hi) = option::some[T](t);
+ hi = (hi + 1u) % _vec::len[cell[T]](elts);
nelts += 1u;
}
@@ -96,21 +96,21 @@ fn create[T]() -> t[T] {
*/
fn pop_front() -> T {
let T t = get[T](elts, lo);
- elts.(lo) = Option.none[T];
- lo = (lo + 1u) % Vec.len[cell[T]](elts);
+ elts.(lo) = option::none[T];
+ lo = (lo + 1u) % _vec::len[cell[T]](elts);
nelts -= 1u;
ret t;
}
fn pop_back() -> T {
if (hi == 0u) {
- hi = Vec.len[cell[T]](elts) - 1u;
+ hi = _vec::len[cell[T]](elts) - 1u;
} else {
hi -= 1u;
}
let T t = get[T](elts, hi);
- elts.(hi) = Option.none[T];
+ elts.(hi) = option::none[T];
nelts -= 1u;
ret t;
}
@@ -124,12 +124,12 @@ fn create[T]() -> t[T] {
}
fn get(int i) -> T {
- let uint idx = (lo + (i as uint)) % Vec.len[cell[T]](elts);
+ let uint idx = (lo + (i as uint)) % _vec::len[cell[T]](elts);
ret get[T](elts, idx);
}
}
- let vec[cell[T]] v = Vec.init_elt[cell[T]](Option.none[T],
+ let vec[cell[T]] v = _vec::init_elt[cell[T]](option::none[T],
initial_capacity);
ret deque[T](0u, 0u, 0u, v);
diff --git a/src/lib/EBML.rs b/src/lib/ebml.rs
index 9b17bf06..0efb05b8 100644
--- a/src/lib/EBML.rs
+++ b/src/lib/ebml.rs
@@ -1,9 +1,9 @@
-// Simple Extensible Binary Markup Language (EBML) reader and writer on a
+// Simple Extensible Binary Markup Language (ebml) reader and writer on a
// cursor model. See the specification here:
// http://www.matroska.org/technical/specs/rfc/index.html
-import Option.none;
-import Option.some;
+import option::none;
+import option::some;
type ebml_tag = rec(uint id, uint size);
type ebml_state = rec(ebml_tag ebml_tag, uint tag_pos, uint data_pos);
@@ -11,7 +11,7 @@ type ebml_state = rec(ebml_tag ebml_tag, uint tag_pos, uint data_pos);
// TODO: When we have module renaming, make "reader" and "writer" separate
// modules within this file.
-// EBML reading
+// ebml reading
type doc = rec(vec[u8] data,
uint start,
@@ -38,7 +38,7 @@ fn vint_at(vec[u8] data, uint start) -> tup(uint, uint) {
}
fn new_doc(vec[u8] data) -> doc {
- ret rec(data=data, start=0u, end=Vec.len[u8](data));
+ ret rec(data=data, start=0u, end=_vec::len[u8](data));
}
fn doc_at(vec[u8] data, uint start) -> doc {
@@ -48,7 +48,7 @@ fn doc_at(vec[u8] data, uint start) -> doc {
ret rec(data=data, start=elt_size._1, end=end);
}
-fn maybe_get_doc(doc d, uint tg) -> Option.t[doc] {
+fn maybe_get_doc(doc d, uint tg) -> option::t[doc] {
auto pos = d.start;
while (pos < d.end) {
auto elt_tag = vint_at(d.data, pos);
@@ -65,7 +65,7 @@ fn get_doc(doc d, uint tg) -> doc {
alt (maybe_get_doc(d, tg)) {
case (some[doc](?d)) {ret d;}
case (none[doc]) {
- log_err "failed to find block with tag " + UInt.to_str(tg, 10u);
+ log_err "failed to find block with tag " + _uint::to_str(tg, 10u);
fail;
}
}
@@ -94,7 +94,7 @@ iter tagged_docs(doc d, uint tg) -> doc {
}
fn doc_data(doc d) -> vec[u8] {
- ret Vec.slice[u8](d.data, d.start, d.end);
+ ret _vec::slice[u8](d.data, d.start, d.end);
}
fn be_uint_from_bytes(vec[u8] data, uint start, uint size) -> uint {
@@ -114,11 +114,11 @@ fn doc_as_uint(doc d) -> uint {
ret be_uint_from_bytes(d.data, d.start, d.end - d.start);
}
-// EBML writing
+// ebml writing
-type writer = rec(IO.buf_writer writer, mutable vec[uint] size_positions);
+type writer = rec(io::buf_writer writer, mutable vec[uint] size_positions);
-fn write_sized_vint(&IO.buf_writer w, uint n, uint size) {
+fn write_sized_vint(&io::buf_writer w, uint n, uint size) {
let vec[u8] buf;
alt (size) {
case (1u) {
@@ -148,7 +148,7 @@ fn write_sized_vint(&IO.buf_writer w, uint n, uint size) {
w.write(buf);
}
-fn write_vint(&IO.buf_writer w, uint n) {
+fn write_vint(&io::buf_writer w, uint n) {
if (n < 0x7fu) { write_sized_vint(w, n, 1u); ret; }
if (n < 0x4000u) { write_sized_vint(w, n, 2u); ret; }
if (n < 0x200000u) { write_sized_vint(w, n, 3u); ret; }
@@ -157,15 +157,15 @@ fn write_vint(&IO.buf_writer w, uint n) {
fail;
}
-fn create_writer(&IO.buf_writer w) -> writer {
+fn create_writer(&io::buf_writer w) -> writer {
let vec[uint] size_positions = vec();
ret rec(writer=w, mutable size_positions=size_positions);
}
-// TODO: Provide a function to write the standard EBML header.
+// TODO: Provide a function to write the standard ebml header.
fn start_tag(&writer w, uint tag_id) {
- // Write the tag ID.
+ // Write the tag ID:
write_vint(w.writer, tag_id);
// Write a placeholder four-byte size.
@@ -175,11 +175,11 @@ fn start_tag(&writer w, uint tag_id) {
}
fn end_tag(&writer w) {
- auto last_size_pos = Vec.pop[uint](w.size_positions);
+ auto last_size_pos = _vec::pop[uint](w.size_positions);
auto cur_pos = w.writer.tell();
- w.writer.seek(last_size_pos as int, IO.seek_set);
+ w.writer.seek(last_size_pos as int, io::seek_set);
write_sized_vint(w.writer, cur_pos - last_size_pos - 4u, 4u);
- w.writer.seek(cur_pos as int, IO.seek_set);
+ w.writer.seek(cur_pos as int, io::seek_set);
}
// TODO: optionally perform "relaxations" on end_tag to more efficiently
diff --git a/src/lib/ExtFmt.rs b/src/lib/extfmt.rs
index 0510a2a8..c5691fe9 100644
--- a/src/lib/ExtFmt.rs
+++ b/src/lib/extfmt.rs
@@ -13,8 +13,8 @@
* combinations at the moment.
*/
-import Option.none;
-import Option.some;
+import option::none;
+import option::some;
/*
* We have a CT (compile-time) module that parses format strings into a
@@ -66,7 +66,7 @@ mod CT {
}
// A formatted conversion from an expression to a string
- type conv = rec(Option.t[int] param,
+ type conv = rec(option::t[int] param,
vec[flag] flags,
count width,
count precision,
@@ -80,11 +80,11 @@ mod CT {
fn parse_fmt_string(str s) -> vec[piece] {
let vec[piece] pieces = vec();
- auto lim = Str.byte_len(s);
+ auto lim = _str::byte_len(s);
auto buf = "";
fn flush_buf(str buf, &vec[piece] pieces) -> str {
- if (Str.byte_len(buf) > 0u) {
+ if (_str::byte_len(buf) > 0u) {
auto piece = piece_string(buf);
pieces += vec(piece);
}
@@ -93,15 +93,15 @@ mod CT {
auto i = 0u;
while (i < lim) {
- auto curr = Str.substr(s, i, 1u);
- if (Str.eq(curr, "%")) {
+ auto curr = _str::substr(s, i, 1u);
+ if (_str::eq(curr, "%")) {
i += 1u;
if (i >= lim) {
log_err "unterminated conversion at end of string";
fail;
}
- auto curr2 = Str.substr(s, i, 1u);
- if (Str.eq(curr2, "%")) {
+ auto curr2 = _str::substr(s, i, 1u);
+ if (_str::eq(curr2, "%")) {
i += 1u;
} else {
buf = flush_buf(buf, pieces);
@@ -118,14 +118,14 @@ mod CT {
ret pieces;
}
- fn peek_num(str s, uint i, uint lim) -> Option.t[tup(uint, uint)] {
+ fn peek_num(str s, uint i, uint lim) -> option::t[tup(uint, uint)] {
if (i >= lim) {
ret none[tup(uint, uint)];
}
auto c = s.(i);
if (!('0' as u8 <= c && c <= '9' as u8)) {
- ret Option.none[tup(uint, uint)];
+ ret option::none[tup(uint, uint)];
}
auto n = (c - ('0' as u8)) as uint;
@@ -156,7 +156,7 @@ mod CT {
ty._1);
}
- fn parse_parameter(str s, uint i, uint lim) -> tup(Option.t[int], uint) {
+ fn parse_parameter(str s, uint i, uint lim) -> tup(option::t[int], uint) {
if (i >= lim) {
ret tup(none[int], i);
}
@@ -270,27 +270,27 @@ mod CT {
}
auto t;
- auto tstr = Str.substr(s, i, 1u);
- if (Str.eq(tstr, "b")) {
+ auto tstr = _str::substr(s, i, 1u);
+ if (_str::eq(tstr, "b")) {
t = ty_bool;
- } else if (Str.eq(tstr, "s")) {
+ } else if (_str::eq(tstr, "s")) {
t = ty_str;
- } else if (Str.eq(tstr, "c")) {
+ } else if (_str::eq(tstr, "c")) {
t = ty_char;
- } else if (Str.eq(tstr, "d")
- || Str.eq(tstr, "i")) {
+ } else if (_str::eq(tstr, "d")
+ || _str::eq(tstr, "i")) {
// TODO: Do we really want two signed types here?
// How important is it to be printf compatible?
t = ty_int(signed);
- } else if (Str.eq(tstr, "u")) {
+ } else if (_str::eq(tstr, "u")) {
t = ty_int(unsigned);
- } else if (Str.eq(tstr, "x")) {
+ } else if (_str::eq(tstr, "x")) {
t = ty_hex(case_lower);
- } else if (Str.eq(tstr, "X")) {
+ } else if (_str::eq(tstr, "X")) {
t = ty_hex(case_upper);
- } else if (Str.eq(tstr, "t")) {
+ } else if (_str::eq(tstr, "t")) {
t = ty_bits;
- } else if (Str.eq(tstr, "o")) {
+ } else if (_str::eq(tstr, "o")) {
t = ty_octal;
} else {
log_err "unknown type in conversion";
@@ -315,7 +315,7 @@ mod RT {
flag_alternate;
// FIXME: This is a hack to avoid creating 0-length vec exprs,
// which have some difficulty typechecking currently. See
- // comments in front.extfmt.make_flags
+ // comments in front::extfmt::make_flags
flag_none;
}
@@ -364,7 +364,7 @@ mod RT {
res = uint_to_str_prec(u, 16u, prec);
}
case (ty_hex_upper) {
- res = Str.to_upper(uint_to_str_prec(u, 16u, prec));
+ res = _str::to_upper(uint_to_str_prec(u, 16u, prec));
}
case (ty_bits) {
res = uint_to_str_prec(u, 2u, prec);
@@ -383,13 +383,13 @@ mod RT {
} else {
s = "false";
}
- // Run the boolean conversion through the string conversion logic,
+ // run the boolean conversion through the string conversion logic,
// giving it the same rules for precision, etc.
ret conv_str(cv, s);
}
fn conv_char(&conv cv, char c) -> str {
- ret pad(cv, Str.from_char(c), pad_nozero);
+ ret pad(cv, _str::from_char(c), pad_nozero);
}
fn conv_str(&conv cv, str s) -> str {
@@ -399,9 +399,9 @@ mod RT {
}
case (count_is(?max)) {
// For strings, precision is the maximum characters displayed
- if (max as uint < Str.char_len(s)) {
+ if (max as uint < _str::char_len(s)) {
// FIXME: substr works on bytes, not chars!
- unpadded = Str.substr(s, 0u, max as uint);
+ unpadded = _str::substr(s, 0u, max as uint);
}
}
}
@@ -420,15 +420,15 @@ mod RT {
// Convert a uint to string with a minimum number of digits. If precision
// is 0 and num is 0 then the result is the empty string. Could move this
- // to UInt. but it doesn't seem all that useful.
+ // to _uint: but it doesn't seem all that useful.
fn uint_to_str_prec(uint num, uint radix, uint prec) -> str {
auto s;
if (prec == 0u && num == 0u) {
s = "";
} else {
- s = UInt.to_str(num, radix);
- auto len = Str.char_len(s);
+ s = _uint::to_str(num, radix);
+ auto len = _str::char_len(s);
if (len < prec) {
auto diff = prec - len;
auto pad = str_init_elt('0', diff);
@@ -450,12 +450,12 @@ mod RT {
}
}
- // FIXME: This might be useful in Str. but needs to be utf8 safe first
+ // FIXME: This might be useful in _str: but needs to be utf8 safe first
fn str_init_elt(char c, uint n_elts) -> str {
- auto svec = Vec.init_elt[u8](c as u8, n_elts);
+ auto svec = _vec::init_elt[u8](c as u8, n_elts);
// FIXME: Using unsafe_from_bytes because rustboot
// can't figure out the is_utf8 predicate on from_bytes?
- ret Str.unsafe_from_bytes(svec);
+ ret _str::unsafe_from_bytes(svec);
}
tag pad_mode {
@@ -476,7 +476,7 @@ mod RT {
}
}
- auto strlen = Str.char_len(s);
+ auto strlen = _str::char_len(s);
if (uwidth <= strlen) {
ret s;
}
@@ -532,16 +532,16 @@ mod RT {
// instead.
if (signed
&& zero_padding
- && Str.byte_len(s) > 0u) {
+ && _str::byte_len(s) > 0u) {
auto head = s.(0);
if (head == '+' as u8
|| head == '-' as u8
|| head == ' ' as u8) {
- auto headstr = Str.unsafe_from_bytes(vec(head));
- auto bytelen = Str.byte_len(s);
- auto numpart = Str.substr(s, 1u, bytelen - 1u);
+ auto headstr = _str::unsafe_from_bytes(vec(head));
+ auto bytelen = _str::byte_len(s);
+ auto numpart = _str::substr(s, 1u, bytelen - 1u);
ret headstr + padstr + numpart;
}
}
diff --git a/src/lib/FS.rs b/src/lib/fs.rs
index 69edf247..a8975769 100644
--- a/src/lib/FS.rs
+++ b/src/lib/fs.rs
@@ -3,43 +3,43 @@ native "rust" mod rustrt {
}
fn path_sep() -> str {
- ret Str.from_char(OS_FS.path_sep);
+ ret _str::from_char(os_fs::path_sep);
}
type path = str;
fn dirname(path p) -> path {
- let int i = Str.rindex(p, OS_FS.path_sep as u8);
+ let int i = _str::rindex(p, os_fs::path_sep as u8);
if (i == -1) {
- i = Str.rindex(p, OS_FS.alt_path_sep as u8);
+ i = _str::rindex(p, os_fs::alt_path_sep as u8);
if (i == -1) {
ret p;
}
}
- ret Str.substr(p, 0u, i as uint);
+ ret _str::substr(p, 0u, i as uint);
}
fn connect(path pre, path post) -> path {
- auto len = Str.byte_len(pre);
- if (pre.(len - 1u) == (OS_FS.path_sep as u8)) { // Trailing '/'?
+ auto len = _str::byte_len(pre);
+ if (pre.(len - 1u) == (os_fs::path_sep as u8)) { // Trailing '/'?
ret pre + post;
}
ret pre + path_sep() + post;
}
fn file_is_dir(path p) -> bool {
- ret rustrt.rust_file_is_dir(p) != 0;
+ ret rustrt::rust_file_is_dir(p) != 0;
}
fn list_dir(path p) -> vec[str] {
- auto pl = Str.byte_len(p);
- if (pl == 0u || p.(pl - 1u) as char != OS_FS.path_sep) {
+ auto pl = _str::byte_len(p);
+ if (pl == 0u || p.(pl - 1u) as char != os_fs::path_sep) {
p += path_sep();
}
let vec[str] full_paths = vec();
- for (str filename in OS_FS.list_dir(p)) {
- if (!Str.eq(filename, ".")) {if (!Str.eq(filename, "..")) {
- Vec.push[str](full_paths, p + filename);
+ for (str filename in os_fs::list_dir(p)) {
+ if (!_str::eq(filename, ".")) {if (!_str::eq(filename, "..")) {
+ _vec::push[str](full_paths, p + filename);
}}
}
ret full_paths;
diff --git a/src/lib/generic_os.rs b/src/lib/generic_os.rs
new file mode 100644
index 00000000..6b2795af
--- /dev/null
+++ b/src/lib/generic_os.rs
@@ -0,0 +1,9 @@
+fn getenv(str n) -> option::t[str] {
+ auto s = os::libc::getenv(_str::buf(n));
+ if ((s as int) == 0) {
+ ret option::none[str];
+ } else {
+ ret option::some[str](_str::str_from_cstr(s));
+ }
+}
+
diff --git a/src/lib/GetOpts.rs b/src/lib/getopts.rs
index 0cacf3ff..c1bcaae3 100644
--- a/src/lib/GetOpts.rs
+++ b/src/lib/getopts.rs
@@ -7,8 +7,8 @@
* argument values out of the match object.
*/
-import Option.some;
-import Option.none;
+import option::some;
+import option::none;
tag name { long(str); short(char); }
tag hasarg { yes; no; maybe; }
@@ -17,7 +17,7 @@ tag occur { req; optional; multi; }
type opt = rec(name name, hasarg hasarg, occur occur);
fn mkname(str nm) -> name {
- if (Str.char_len(nm) == 1u) { ret short(Str.char_at(nm, 0u)); }
+ if (_str::char_len(nm) == 1u) { ret short(_str::char_at(nm, 0u)); }
else { ret long(nm); }
}
fn reqopt(str name) -> opt {
@@ -41,11 +41,11 @@ tag optval {
type match = rec(vec[opt] opts, vec[mutable vec[optval]] vals, vec[str] free);
fn is_arg(str arg) -> bool {
- ret Str.byte_len(arg) > 1u && arg.(0) == '-' as u8;
+ ret _str::byte_len(arg) > 1u && arg.(0) == '-' as u8;
}
fn name_str(name nm) -> str {
alt (nm) {
- case (short(?ch)) {ret Str.from_char(ch);}
+ case (short(?ch)) {ret _str::from_char(ch);}
case (long(?s)) {ret s;}
}
}
@@ -55,16 +55,16 @@ fn name_eq(name a, name b) -> bool {
alt (a) {
case (long(?a)) {
alt (b) {
- case (long(?b)) { ret Str.eq(a, b); }
+ case (long(?b)) { ret _str::eq(a, b); }
case (_) { ret false; }
}
}
case (_) { if (a == b) { ret true; } else {ret false; } }
}
}
-fn find_opt(vec[opt] opts, name nm) -> Option.t[uint] {
+fn find_opt(vec[opt] opts, name nm) -> option::t[uint] {
auto i = 0u;
- auto l = Vec.len[opt](opts);
+ auto l = _vec::len[opt](opts);
while (i < l) {
if (name_eq(opts.(i).name, nm)) { ret some[uint](i); }
i += 1u;
@@ -91,7 +91,7 @@ fn fail_str(fail_ f) -> str {
ret "Required option '" + nm + "' missing.";
}
case (option_duplicated(?nm)) {
- ret "Option '" + nm + "' given more than once.";
+ ret "option '" + nm + "' given more than once.";
}
}
}
@@ -102,41 +102,41 @@ tag result {
}
fn getopts(vec[str] args, vec[opt] opts) -> result {
- auto n_opts = Vec.len[opt](opts);
- fn empty_(uint x) -> vec[optval]{ret Vec.empty[optval]();}
+ auto n_opts = _vec::len[opt](opts);
+ fn empty_(uint x) -> vec[optval]{ret _vec::empty[optval]();}
auto f = empty_;
- auto vals = Vec.init_fn_mut[vec[optval]](f, n_opts);
+ auto vals = _vec::init_fn_mut[vec[optval]](f, n_opts);
let vec[str] free = vec();
- auto l = Vec.len[str](args);
+ auto l = _vec::len[str](args);
auto i = 0u;
while (i < l) {
auto cur = args.(i);
- auto curlen = Str.byte_len(cur);
+ auto curlen = _str::byte_len(cur);
if (!is_arg(cur)) {
- Vec.push[str](free, cur);
- } else if (Str.eq(cur, "--")) {
- free += Vec.slice[str](args, i + 1u, l);
+ _vec::push[str](free, cur);
+ } else if (_str::eq(cur, "--")) {
+ free += _vec::slice[str](args, i + 1u, l);
break;
} else {
auto names;
- auto i_arg = Option.none[str];
+ auto i_arg = option::none[str];
if (cur.(1) == '-' as u8) {
- auto tail = Str.slice(cur, 2u, curlen);
- auto eq = Str.index(tail, '=' as u8);
+ auto tail = _str::slice(cur, 2u, curlen);
+ auto eq = _str::index(tail, '=' as u8);
if (eq == -1) {
names = vec(long(tail));
} else {
- names = vec(long(Str.slice(tail, 0u, eq as uint)));
- i_arg = Option.some[str]
- (Str.slice(tail, (eq as uint) + 1u, curlen - 2u));
+ names = vec(long(_str::slice(tail, 0u, eq as uint)));
+ i_arg = option::some[str]
+ (_str::slice(tail, (eq as uint) + 1u, curlen - 2u));
}
} else {
auto j = 1u;
names = vec();
while (j < curlen) {
- auto range = Str.char_range_at(cur, j);
- Vec.push[name](names, short(range._0));
+ auto range = _str::char_range_at(cur, j);
+ _vec::push[name](names, short(range._0));
j = range._1;
}
}
@@ -152,29 +152,29 @@ fn getopts(vec[str] args, vec[opt] opts) -> result {
}
alt (opts.(optid).hasarg) {
case (no) {
- Vec.push[optval](vals.(optid), given);
+ _vec::push[optval](vals.(optid), given);
}
case (maybe) {
- if (!Option.is_none[str](i_arg)) {
- Vec.push[optval](vals.(optid),
- val(Option.get[str](i_arg)));
- } else if (name_pos < Vec.len[name](names) ||
+ if (!option::is_none[str](i_arg)) {
+ _vec::push[optval](vals.(optid),
+ val(option::get[str](i_arg)));
+ } else if (name_pos < _vec::len[name](names) ||
i + 1u == l || is_arg(args.(i + 1u))) {
- Vec.push[optval](vals.(optid), given);
+ _vec::push[optval](vals.(optid), given);
} else {
i += 1u;
- Vec.push[optval](vals.(optid), val(args.(i)));
+ _vec::push[optval](vals.(optid), val(args.(i)));
}
}
case (yes) {
- if (!Option.is_none[str](i_arg)) {
- Vec.push[optval](vals.(optid),
- val(Option.get[str](i_arg)));
+ if (!option::is_none[str](i_arg)) {
+ _vec::push[optval](vals.(optid),
+ val(option::get[str](i_arg)));
} else if (i + 1u == l) {
ret failure(argument_missing(name_str(nm)));
} else {
i += 1u;
- Vec.push[optval](vals.(optid), val(args.(i)));
+ _vec::push[optval](vals.(optid), val(args.(i)));
}
}
}
@@ -185,7 +185,7 @@ fn getopts(vec[str] args, vec[opt] opts) -> result {
i = 0u;
while (i < n_opts) {
- auto n = Vec.len[optval](vals.(i));
+ auto n = _vec::len[optval](vals.(i));
auto occ = opts.(i).occur;
if (occ == req) {if (n == 0u) {
ret failure(option_missing(name_str(opts.(i).name)));
@@ -212,7 +212,7 @@ fn opt_val(match m, str nm) -> optval {
ret opt_vals(m, nm).(0);
}
fn opt_present(match m, str nm) -> bool {
- ret Vec.len[optval](opt_vals(m, nm)) > 0u;
+ ret _vec::len[optval](opt_vals(m, nm)) > 0u;
}
fn opt_str(match m, str nm) -> str {
alt (opt_val(m, nm)) {
@@ -224,15 +224,15 @@ fn opt_strs(match m, str nm) -> vec[str] {
let vec[str] acc = vec();
for (optval v in opt_vals(m, nm)) {
alt (v) {
- case (val(?s)) { Vec.push[str](acc, s); }
+ case (val(?s)) { _vec::push[str](acc, s); }
case (_) {}
}
}
ret acc;
}
-fn opt_maybe_str(match m, str nm) -> Option.t[str] {
+fn opt_maybe_str(match m, str nm) -> option::t[str] {
auto vals = opt_vals(m, nm);
- if (Vec.len[optval](vals) == 0u) { ret none[str]; }
+ if (_vec::len[optval](vals) == 0u) { ret none[str]; }
alt (vals.(0)) {
case (val(?s)) { ret some[str](s); }
case (_) { ret none[str]; }
diff --git a/src/lib/IO.rs b/src/lib/io.rs
index c0ae2c2f..c996584f 100644
--- a/src/lib/IO.rs
+++ b/src/lib/io.rs
@@ -1,8 +1,8 @@
-import OS.libc;
+import os::libc;
native "rust" mod rustrt {
- fn rust_get_stdin() -> OS.libc.FILE;
- fn rust_get_stdout() -> OS.libc.FILE;
+ fn rust_get_stdin() -> os::libc::FILE;
+ fn rust_get_stdout() -> os::libc::FILE;
}
// Reading
@@ -55,30 +55,30 @@ fn convert_whence(seek_style whence) -> int {
}
}
-state obj FILE_buf_reader(OS.libc.FILE f, bool must_close) {
+state obj FILE_buf_reader(os::libc::FILE f, bool must_close) {
fn read(uint len) -> vec[u8] {
- auto buf = Vec.alloc[u8](len);
- auto read = OS.libc.fread(Vec.buf[u8](buf), 1u, len, f);
- Vec.len_set[u8](buf, read);
+ auto buf = _vec::alloc[u8](len);
+ auto read = os::libc::fread(_vec::buf[u8](buf), 1u, len, f);
+ _vec::len_set[u8](buf, read);
ret buf;
}
fn read_byte() -> int {
- ret OS.libc.fgetc(f);
+ ret os::libc::fgetc(f);
}
fn unread_byte(int byte) {
- OS.libc.ungetc(byte, f);
+ os::libc::ungetc(byte, f);
}
fn eof() -> bool {
- ret OS.libc.feof(f) != 0;
+ ret os::libc::feof(f) != 0;
}
fn seek(int offset, seek_style whence) {
- assert (OS.libc.fseek(f, offset, convert_whence(whence)) == 0);
+ assert (os::libc::fseek(f, offset, convert_whence(whence)) == 0);
}
fn tell() -> uint {
- ret OS.libc.ftell(f) as uint;
+ ret os::libc::ftell(f) as uint;
}
drop {
- if (must_close) { OS.libc.fclose(f); }
+ if (must_close) { os::libc::fclose(f); }
}
}
@@ -100,7 +100,7 @@ state obj new_reader(buf_reader rdr) {
auto c0 = rdr.read_byte();
if (c0 == -1) {ret -1 as char;} // FIXME will this stay valid?
auto b0 = c0 as u8;
- auto w = Str.utf8_char_width(b0);
+ auto w = _str::utf8_char_width(b0);
assert (w > 0u);
if (w == 1u) {ret b0 as char;}
auto val = 0u;
@@ -112,7 +112,7 @@ state obj new_reader(buf_reader rdr) {
val <<= 6u;
val += (next & 0x3f) as uint;
}
- // See Str.char_at
+ // See _str::char_at
val += ((b0 << ((w + 1u) as u8)) as uint) << ((w - 1u) * 6u - w - 1u);
ret val as char;
}
@@ -126,9 +126,9 @@ state obj new_reader(buf_reader rdr) {
while (go_on) {
auto ch = rdr.read_byte();
if (ch == -1 || ch == 10) {go_on = false;}
- else {Vec.push[u8](buf, ch as u8);}
+ else {_vec::push[u8](buf, ch as u8);}
}
- ret Str.unsafe_from_bytes(buf);
+ ret _str::unsafe_from_bytes(buf);
}
fn read_c_str() -> str {
let vec[u8] buf = vec();
@@ -136,9 +136,9 @@ state obj new_reader(buf_reader rdr) {
while (go_on) {
auto ch = rdr.read_byte();
if (ch < 1) {go_on = false;}
- else {Vec.push[u8](buf, ch as u8);}
+ else {_vec::push[u8](buf, ch as u8);}
}
- ret Str.unsafe_from_bytes(buf);
+ ret _str::unsafe_from_bytes(buf);
}
// FIXME deal with eof?
fn read_le_uint(uint size) -> uint {
@@ -164,7 +164,7 @@ state obj new_reader(buf_reader rdr) {
// FIXME deal with eof?
fn read_be_uint(uint size) -> uint {
auto val = 0u;
- auto sz = size; // FIXME: trans.ml bug workaround
+ auto sz = size; // FIXME: trans::ml bug workaround
while (sz > 0u) {
sz -= 1u;
val += (rdr.read_byte() as uint) << (sz * 8u);
@@ -187,11 +187,11 @@ state obj new_reader(buf_reader rdr) {
}
fn stdin() -> reader {
- ret new_reader(FILE_buf_reader(rustrt.rust_get_stdin(), false));
+ ret new_reader(FILE_buf_reader(rustrt::rust_get_stdin(), false));
}
fn file_reader(str path) -> reader {
- auto f = OS.libc.fopen(Str.buf(path), Str.buf("r"));
+ auto f = os::libc::fopen(_str::buf(path), _str::buf("r"));
if (f as uint == 0u) {
log_err "error opening " + path;
fail;
@@ -212,17 +212,17 @@ type byte_buf = @rec(vec[u8] buf, mutable uint pos);
state obj byte_buf_reader(byte_buf bbuf) {
fn read(uint len) -> vec[u8] {
- auto rest = Vec.len[u8](bbuf.buf) - bbuf.pos;
+ auto rest = _vec::len[u8](bbuf.buf) - bbuf.pos;
auto to_read = len;
if (rest < to_read) {
to_read = rest;
}
- auto range = Vec.slice[u8](bbuf.buf, bbuf.pos, bbuf.pos + to_read);
+ auto range = _vec::slice[u8](bbuf.buf, bbuf.pos, bbuf.pos + to_read);
bbuf.pos += to_read;
ret range;
}
fn read_byte() -> int {
- if (bbuf.pos == Vec.len[u8](bbuf.buf)) {ret -1;}
+ if (bbuf.pos == _vec::len[u8](bbuf.buf)) {ret -1;}
auto b = bbuf.buf.(bbuf.pos);
bbuf.pos += 1u;
ret b as int;
@@ -234,12 +234,12 @@ state obj byte_buf_reader(byte_buf bbuf) {
}
fn eof() -> bool {
- ret bbuf.pos == Vec.len[u8](bbuf.buf);
+ ret bbuf.pos == _vec::len[u8](bbuf.buf);
}
fn seek(int offset, seek_style whence) {
auto pos = bbuf.pos;
- auto len = Vec.len[u8](bbuf.buf);
+ auto len = _vec::len[u8](bbuf.buf);
bbuf.pos = seek_in_buf(offset, pos, len, whence);
}
@@ -268,40 +268,40 @@ type buf_writer = state obj {
fn tell() -> uint; // FIXME: eventually u64
};
-state obj FILE_writer(OS.libc.FILE f, bool must_close) {
+state obj FILE_writer(os::libc::FILE f, bool must_close) {
fn write(vec[u8] v) {
- auto len = Vec.len[u8](v);
- auto vbuf = Vec.buf[u8](v);
- auto nout = OS.libc.fwrite(vbuf, len, 1u, f);
+ auto len = _vec::len[u8](v);
+ auto vbuf = _vec::buf[u8](v);
+ auto nout = os::libc::fwrite(vbuf, len, 1u, f);
if (nout < 1u) {
log_err "error dumping buffer";
}
}
fn seek(int offset, seek_style whence) {
- assert (OS.libc.fseek(f, offset, convert_whence(whence)) == 0);
+ assert (os::libc::fseek(f, offset, convert_whence(whence)) == 0);
}
fn tell() -> uint {
- ret OS.libc.ftell(f) as uint;
+ ret os::libc::ftell(f) as uint;
}
drop {
- if (must_close) {OS.libc.fclose(f);}
+ if (must_close) {os::libc::fclose(f);}
}
}
state obj fd_buf_writer(int fd, bool must_close) {
fn write(vec[u8] v) {
- auto len = Vec.len[u8](v);
+ auto len = _vec::len[u8](v);
auto count = 0u;
auto vbuf;
while (count < len) {
- vbuf = Vec.buf_off[u8](v, count);
- auto nout = OS.libc.write(fd, vbuf, len);
+ vbuf = _vec::buf_off[u8](v, count);
+ auto nout = os::libc::write(fd, vbuf, len);
if (nout < 0) {
log_err "error dumping buffer";
- log_err Sys.rustrt.last_os_error();
+ log_err sys::rustrt::last_os_error();
fail;
}
count += nout as uint;
@@ -319,32 +319,32 @@ state obj fd_buf_writer(int fd, bool must_close) {
}
drop {
- if (must_close) {OS.libc.close(fd);}
+ if (must_close) {os::libc::close(fd);}
}
}
fn file_buf_writer(str path, vec[fileflag] flags) -> buf_writer {
let int fflags =
- OS.libc_constants.O_WRONLY() |
- OS.libc_constants.O_BINARY();
+ os::libc_constants::O_WRONLY() |
+ os::libc_constants::O_BINARY();
for (fileflag f in flags) {
alt (f) {
- case (append) { fflags |= OS.libc_constants.O_APPEND(); }
- case (create) { fflags |= OS.libc_constants.O_CREAT(); }
- case (truncate) { fflags |= OS.libc_constants.O_TRUNC(); }
+ case (append) { fflags |= os::libc_constants::O_APPEND(); }
+ case (create) { fflags |= os::libc_constants::O_CREAT(); }
+ case (truncate) { fflags |= os::libc_constants::O_TRUNC(); }
case (none) {}
}
}
- auto fd = OS.libc.open(Str.buf(path),
+ auto fd = os::libc::open(_str::buf(path),
fflags,
- OS.libc_constants.S_IRUSR() |
- OS.libc_constants.S_IWUSR());
+ os::libc_constants::S_IRUSR() |
+ os::libc_constants::S_IWUSR());
if (fd < 0) {
log_err "error opening file for writing";
- log_err Sys.rustrt.last_os_error();
+ log_err sys::rustrt::last_os_error();
fail;
}
ret fd_buf_writer(fd, true);
@@ -390,17 +390,17 @@ state obj new_writer(buf_writer out) {
ret out;
}
fn write_str(str s) {
- out.write(Str.bytes(s));
+ out.write(_str::bytes(s));
}
fn write_char(char ch) {
// FIXME needlessly consy
- out.write(Str.bytes(Str.from_char(ch)));
+ out.write(_str::bytes(_str::from_char(ch)));
}
fn write_int(int n) {
- out.write(Str.bytes(Int.to_str(n, 10u)));
+ out.write(_str::bytes(_int::to_str(n, 10u)));
}
fn write_uint(uint n) {
- out.write(Str.bytes(UInt.to_str(n, 10u)));
+ out.write(_str::bytes(_uint::to_str(n, 10u)));
}
fn write_bytes(vec[u8] bytes) {
out.write(bytes);
@@ -427,7 +427,7 @@ fn file_writer(str path, vec[fileflag] flags) -> writer {
// FIXME: fileflags
fn buffered_file_buf_writer(str path) -> buf_writer {
- auto f = OS.libc.fopen(Str.buf(path), Str.buf("w"));
+ auto f = os::libc::fopen(_str::buf(path), _str::buf("w"));
if (f as uint == 0u) {
log_err "error opening " + path;
fail;
@@ -451,21 +451,21 @@ type mutable_byte_buf = @rec(mutable vec[mutable u8] buf, mutable uint pos);
state obj byte_buf_writer(mutable_byte_buf buf) {
fn write(vec[u8] v) {
// Fast path.
- if (buf.pos == Vec.len(buf.buf)) {
+ if (buf.pos == _vec::len(buf.buf)) {
// FIXME: Fix our type system. There's no reason you shouldn't be
// able to add a mutable vector to an immutable one.
- auto mv = Vec.rustrt.unsafe_vec_to_mut[u8](v);
+ auto mv = _vec::rustrt::unsafe_vec_to_mut[u8](v);
buf.buf += mv;
- buf.pos += Vec.len[u8](v);
+ buf.pos += _vec::len[u8](v);
ret;
}
- // FIXME: Optimize. These should be unique pointers.
- auto vlen = Vec.len[u8](v);
+ // FIXME: Optimize: These should be unique pointers.
+ auto vlen = _vec::len[u8](v);
auto vpos = 0u;
while (vpos < vlen) {
auto b = v.(vpos);
- if (buf.pos == Vec.len(buf.buf)) {
+ if (buf.pos == _vec::len(buf.buf)) {
buf.buf += vec(mutable b);
} else {
buf.buf.(buf.pos) = b;
@@ -477,7 +477,7 @@ state obj byte_buf_writer(mutable_byte_buf buf) {
fn seek(int offset, seek_style whence) {
auto pos = buf.pos;
- auto len = Vec.len(buf.buf);
+ auto len = _vec::len(buf.buf);
buf.pos = seek_in_buf(offset, pos, len, whence);
}
@@ -487,12 +487,12 @@ state obj byte_buf_writer(mutable_byte_buf buf) {
fn string_writer() -> str_writer {
// FIXME: yikes, this is bad. Needs fixing of mutable syntax.
let vec[mutable u8] b = vec(mutable 0u8);
- Vec.pop(b);
+ _vec::pop(b);
let mutable_byte_buf buf = @rec(mutable buf = b, mutable pos = 0u);
state obj str_writer_wrap(writer wr, mutable_byte_buf buf) {
fn get_writer() -> writer {ret wr;}
- fn get_str() -> str {ret Str.unsafe_from_bytes(buf.buf);}
+ fn get_str() -> str {ret _str::unsafe_from_bytes(buf.buf);}
}
ret str_writer_wrap(new_writer(byte_buf_writer(buf)), buf);
}
diff --git a/src/lib/linux_OS.rs b/src/lib/linux_os.rs
index 02c9183b..3b074e41 100644
--- a/src/lib/linux_OS.rs
+++ b/src/lib/linux_os.rs
@@ -1,10 +1,10 @@
-import Str.sbuf;
-import Vec.vbuf;
+import _str::sbuf;
+import _vec::vbuf;
// FIXME Somehow merge stuff duplicated here and macosx_os.rs. Made difficult
// by https://github.com/graydon/rust/issues#issue/268
-native mod libc = "libc.so.6" {
+native mod libc = "libc::so.6" {
fn open(sbuf s, int flags, uint mode) -> int;
fn read(int fd, vbuf buf, uint count) -> int;
@@ -66,17 +66,17 @@ fn dylib_filename(str base) -> str {
fn pipe() -> tup(int, int) {
let vec[mutable int] fds = vec(mutable 0, 0);
- assert (OS.libc.pipe(Vec.buf(fds)) == 0);
+ assert (os::libc::pipe(_vec::buf(fds)) == 0);
ret tup(fds.(0), fds.(1));
}
-fn fd_FILE(int fd) -> libc.FILE {
- ret libc.fdopen(fd, Str.buf("r"));
+fn fd_FILE(int fd) -> libc::FILE {
+ ret libc::fdopen(fd, _str::buf("r"));
}
fn waitpid(int pid) -> int {
let vec[mutable int] status = vec(mutable 0);
- assert (OS.libc.waitpid(pid, Vec.buf(status), 0) != -1);
+ assert (os::libc::waitpid(pid, _vec::buf(status), 0) != -1);
ret status.(0);
}
diff --git a/src/lib/List.rs b/src/lib/list.rs
index 6d7748f0..86d6c21d 100644
--- a/src/lib/List.rs
+++ b/src/lib/list.rs
@@ -1,5 +1,5 @@
-import Option.some;
-import Option.none;
+import option::some;
+import option::none;
// FIXME: It would probably be more appealing to define this as
// type list[T] = rec(T hd, option[@list[T]] tl), but at the moment
@@ -27,7 +27,7 @@ fn foldl[T,U](&list[T] ls, &U u, fn(&T t, &U u) -> U f) -> U {
}
fn find[T,U](&list[T] ls,
- (fn(&T) -> Option.t[U]) f) -> Option.t[U] {
+ (fn(&T) -> option::t[U]) f) -> option::t[U] {
alt(ls) {
case (cons[T](?hd, ?tl)) {
alt (f(hd)) {
diff --git a/src/lib/macos_OS.rs b/src/lib/macos_os.rs
index 2cd6894f..2ad89319 100644
--- a/src/lib/macos_OS.rs
+++ b/src/lib/macos_os.rs
@@ -1,7 +1,7 @@
-import Str.sbuf;
-import Vec.vbuf;
+import _str::sbuf;
+import _vec::vbuf;
-native mod libc = "libc.dylib" {
+native mod libc = "libc::dylib" {
fn open(sbuf s, int flags, uint mode) -> int;
fn read(int fd, vbuf buf, uint count) -> int;
@@ -63,17 +63,17 @@ fn dylib_filename(str base) -> str {
fn pipe() -> tup(int, int) {
let vec[mutable int] fds = vec(mutable 0, 0);
- assert (OS.libc.pipe(Vec.buf(fds)) == 0);
+ assert (os::libc::pipe(_vec::buf(fds)) == 0);
ret tup(fds.(0), fds.(1));
}
-fn fd_FILE(int fd) -> libc.FILE {
- ret libc.fdopen(fd, Str.buf("r"));
+fn fd_FILE(int fd) -> libc::FILE {
+ ret libc::fdopen(fd, _str::buf("r"));
}
fn waitpid(int pid) -> int {
let vec[mutable int] status = vec(mutable 0);
- assert (OS.libc.waitpid(pid, Vec.buf(status), 0) != -1);
+ assert (os::libc::waitpid(pid, _vec::buf(status), 0) != -1);
ret status.(0);
}
diff --git a/src/lib/Map.rs b/src/lib/map.rs
index 6f1ad6d7..5483dccf 100644
--- a/src/lib/Map.rs
+++ b/src/lib/map.rs
@@ -11,8 +11,8 @@ state type hashmap[K, V] = state obj {
fn insert(&K key, &V val) -> bool;
fn contains_key(&K key) -> bool;
fn get(&K key) -> V;
- fn find(&K key) -> Option.t[V];
- fn remove(&K key) -> Option.t[V];
+ fn find(&K key) -> option::t[V];
+ fn remove(&K key) -> option::t[V];
fn rehash();
iter items() -> @tup(K,V);
};
@@ -20,7 +20,7 @@ state type hashmap[K, V] = state obj {
fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] {
let uint initial_capacity = 32u; // 2^5
- let Util.rational load_factor = rec(num=3, den=4);
+ let util::rational load_factor = rec(num=3, den=4);
tag bucket[K, V] {
nil;
@@ -29,7 +29,7 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] {
}
fn make_buckets[K, V](uint nbkts) -> vec[mutable bucket[K, V]] {
- ret Vec.init_elt_mut[bucket[K, V]](nil[K, V], nbkts);
+ ret _vec::init_elt_mut[bucket[K, V]](nil[K, V], nbkts);
}
// Derive two hash functions from the one given by taking the upper
@@ -96,7 +96,7 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] {
vec[mutable bucket[K, V]] bkts,
uint nbkts,
&K key)
- -> Option.t[V]
+ -> option::t[V]
{
let uint i = 0u;
let uint h = hasher(key);
@@ -105,17 +105,17 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] {
alt (bkts.(j)) {
case (some[K, V](?k, ?v)) {
if (eqer(key, k)) {
- ret Option.some[V](v);
+ ret option::some[V](v);
}
}
case (nil[K, V]) {
- ret Option.none[V];
+ ret option::none[V];
}
case (deleted[K, V]) { }
}
i += 1u;
}
- ret Option.none[V];
+ ret option::none[V];
}
@@ -140,15 +140,15 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] {
mutable vec[mutable bucket[K, V]] bkts,
mutable uint nbkts,
mutable uint nelts,
- Util.rational lf)
+ util::rational lf)
{
fn size() -> uint { ret nelts; }
fn insert(&K key, &V val) -> bool {
- let Util.rational load = rec(num=(nelts + 1u) as int,
+ let util::rational load = rec(num=(nelts + 1u) as int,
den=nbkts as int);
- if (!Util.rational_leq(load, lf)) {
- let uint nnewbkts = UInt.next_power_of_two(nbkts + 1u);
+ if (!util::rational_leq(load, lf)) {
+ let uint nnewbkts = _uint::next_power_of_two(nbkts + 1u);
let vec[mutable bucket[K, V]] newbkts =
make_buckets[K, V](nnewbkts);
rehash[K, V](hasher, eqer, bkts, nbkts,
@@ -167,7 +167,7 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] {
fn contains_key(&K key) -> bool {
alt (find_common[K, V](hasher, eqer, bkts, nbkts, key)) {
- case (Option.some[V](_)) { ret true; }
+ case (option::some[V](_)) { ret true; }
case (_) { ret false; }
}
fail; // FIXME: remove me when exhaustiveness checking works
@@ -175,19 +175,19 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] {
fn get(&K key) -> V {
alt (find_common[K, V](hasher, eqer, bkts, nbkts, key)) {
- case (Option.some[V](?val)) { ret val; }
+ case (option::some[V](?val)) { ret val; }
case (_) { fail; }
}
fail; // FIXME: remove me when exhaustiveness checking works
}
- fn find(&K key) -> Option.t[V] {
+ fn find(&K key) -> option::t[V] {
// FIXME: should be 'be' but parametric tail-calls don't
// work at the moment.
ret find_common[K, V](hasher, eqer, bkts, nbkts, key);
}
- fn remove(&K key) -> Option.t[V] {
+ fn remove(&K key) -> option::t[V] {
let uint i = 0u;
let uint h = hasher(key);
while (i < nbkts) {
@@ -197,17 +197,17 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] {
if (eqer(key, k)) {
bkts.(j) = deleted[K, V];
nelts -= 1u;
- ret Option.some[V](v);
+ ret option::some[V](v);
}
}
case (deleted[K, V]) { }
case (nil[K, V]) {
- ret Option.none[V];
+ ret option::none[V];
}
}
i += 1u;
}
- ret Option.none[V];
+ ret option::none[V];
}
fn rehash() {
diff --git a/src/lib/Option.rs b/src/lib/option.rs
index 3fb9aa3b..78ed2fb3 100644
--- a/src/lib/Option.rs
+++ b/src/lib/option.rs
@@ -1,4 +1,4 @@
-// lib/Option.rs
+// lib/option::rs
tag t[T] {
none;
@@ -39,7 +39,7 @@ fn is_none[T](&t[T] opt) -> bool {
}
fn from_maybe[T](&T def, &t[T] opt) -> T {
- auto f = bind Util.id[T](_);
+ auto f = bind util::id[T](_);
ret maybe[T, T](def, f, opt);
}
diff --git a/src/lib/posix_FS.rs b/src/lib/posix_fs.rs
index b1f01a66..1244dd1b 100644
--- a/src/lib/posix_FS.rs
+++ b/src/lib/posix_fs.rs
@@ -1,21 +1,21 @@
native "rust" mod rustrt {
- fn rust_dirent_filename(OS.libc.dirent ent) -> str;
+ fn rust_dirent_filename(os::libc::dirent ent) -> str;
}
fn list_dir(str path) -> vec[str] {
// TODO ensure this is always closed
- auto dir = OS.libc.opendir(Str.buf(path));
+ auto dir = os::libc::opendir(_str::buf(path));
assert (dir as uint != 0u);
let vec[str] result = vec();
while (true) {
- auto ent = OS.libc.readdir(dir);
+ auto ent = os::libc::readdir(dir);
if (ent as int == 0) {
- OS.libc.closedir(dir);
+ os::libc::closedir(dir);
ret result;
}
- Vec.push[str](result, rustrt.rust_dirent_filename(ent));
+ _vec::push[str](result, rustrt::rust_dirent_filename(ent));
}
- OS.libc.closedir(dir);
+ os::libc::closedir(dir);
ret result;
}
diff --git a/src/lib/Rand.rs b/src/lib/rand.rs
index 06eb2f06..da8f552f 100644
--- a/src/lib/Rand.rs
+++ b/src/lib/rand.rs
@@ -12,16 +12,16 @@ native "rust" mod rustrt {
type rng = obj { fn next() -> u32; };
fn mk_rng() -> rng {
- obj rt_rng(rustrt.rctx c) {
+ obj rt_rng(rustrt::rctx c) {
fn next() -> u32 {
- ret rustrt.rand_next(c);
+ ret rustrt::rand_next(c);
}
drop {
- rustrt.rand_free(c);
+ rustrt::rand_free(c);
}
}
- ret rt_rng(rustrt.rand_new());
+ ret rt_rng(rustrt::rand_new());
}
// Local Variables:
diff --git a/src/lib/Run_Program.rs b/src/lib/run_program.rs
index 30c0ee9c..abcf1472 100644
--- a/src/lib/Run_Program.rs
+++ b/src/lib/run_program.rs
@@ -1,74 +1,74 @@
-import Str.sbuf;
-import Vec.vbuf;
+import _str::sbuf;
+import _vec::vbuf;
native "rust" mod rustrt {
fn rust_run_program(vbuf argv, int in_fd, int out_fd, int err_fd) -> int;
}
fn argvec(str prog, vec[str] args) -> vec[sbuf] {
- auto argptrs = vec(Str.buf(prog));
+ auto argptrs = vec(_str::buf(prog));
for (str arg in args) {
- Vec.push[sbuf](argptrs, Str.buf(arg));
+ _vec::push[sbuf](argptrs, _str::buf(arg));
}
- Vec.push[sbuf](argptrs, 0 as sbuf);
+ _vec::push[sbuf](argptrs, 0 as sbuf);
ret argptrs;
}
fn run_program(str prog, vec[str] args) -> int {
- auto pid = rustrt.rust_run_program(Vec.buf[sbuf](argvec(prog, args)),
+ auto pid = rustrt::rust_run_program(_vec::buf[sbuf](argvec(prog, args)),
0, 0, 0);
- ret OS.waitpid(pid);
+ ret os::waitpid(pid);
}
type program =
state obj {
fn get_id() -> int;
- fn input() -> IO.writer;
- fn output() -> IO.reader;
+ fn input() -> io::writer;
+ fn output() -> io::reader;
fn close_input();
fn finish() -> int;
};
fn start_program(str prog, vec[str] args) -> @program {
- auto pipe_input = OS.pipe();
- auto pipe_output = OS.pipe();
- auto pid = rustrt.rust_run_program
- (Vec.buf[sbuf](argvec(prog, args)),
+ auto pipe_input = os::pipe();
+ auto pipe_output = os::pipe();
+ auto pid = rustrt::rust_run_program
+ (_vec::buf[sbuf](argvec(prog, args)),
pipe_input._0, pipe_output._1, 0);
if (pid == -1) {fail;}
- OS.libc.close(pipe_input._0);
- OS.libc.close(pipe_output._1);
+ os::libc::close(pipe_input._0);
+ os::libc::close(pipe_output._1);
state obj new_program(int pid,
int in_fd,
- OS.libc.FILE out_file,
+ os::libc::FILE out_file,
mutable bool finished) {
fn get_id() -> int {ret pid;}
- fn input() -> IO.writer {
- ret IO.new_writer(IO.fd_buf_writer(in_fd, false));
+ fn input() -> io::writer {
+ ret io::new_writer(io::fd_buf_writer(in_fd, false));
}
- fn output() -> IO.reader {
- ret IO.new_reader(IO.FILE_buf_reader(out_file, false));
+ fn output() -> io::reader {
+ ret io::new_reader(io::FILE_buf_reader(out_file, false));
}
fn close_input() {
- OS.libc.close(in_fd);
+ os::libc::close(in_fd);
}
fn finish() -> int {
if (finished) {ret 0;}
finished = true;
- OS.libc.close(in_fd);
- ret OS.waitpid(pid);
+ os::libc::close(in_fd);
+ ret os::waitpid(pid);
}
drop {
if (!finished) {
- OS.libc.close(in_fd);
- OS.waitpid(pid);
+ os::libc::close(in_fd);
+ os::waitpid(pid);
}
- OS.libc.fclose(out_file);
+ os::libc::fclose(out_file);
}
}
ret @new_program(pid, pipe_input._1,
- OS.fd_FILE(pipe_output._0),
+ os::fd_FILE(pipe_output._0),
false);
}
@@ -80,7 +80,7 @@ fn program_output(str prog, vec[str] args)
auto buf = "";
while (!out.eof()) {
auto bytes = out.read_bytes(4096u);
- buf += Str.unsafe_from_bytes(bytes);
+ buf += _str::unsafe_from_bytes(bytes);
}
ret rec(status=pr.finish(), out=buf);
}
diff --git a/src/lib/SHA1.rs b/src/lib/sha1.rs
index 6aec814c..96535d12 100644
--- a/src/lib/SHA1.rs
+++ b/src/lib/sha1.rs
@@ -74,8 +74,8 @@ fn mk_sha1() -> sha1 {
fn process_msg_block(&sha1state st) {
// FIXME: Make precondition
- assert (Vec.len(st.h) == digest_buf_len);
- assert (Vec.len(st.work_buf) == work_buf_len);
+ assert (_vec::len(st.h) == digest_buf_len);
+ assert (_vec::len(st.work_buf) == work_buf_len);
let int t; // Loop counter
auto w = st.work_buf;
@@ -196,7 +196,7 @@ fn mk_sha1() -> sha1 {
*/
fn pad_msg(&sha1state st) {
// FIXME: Should be a precondition
- assert (Vec.len(st.msg_block) == msg_block_len);
+ assert (_vec::len(st.msg_block) == msg_block_len);
/*
* Check to see if the current message block is too small to hold
@@ -240,7 +240,7 @@ fn mk_sha1() -> sha1 {
fn reset() {
// FIXME: Should be typestate precondition
- assert (Vec.len(st.h) == digest_buf_len);
+ assert (_vec::len(st.h) == digest_buf_len);
st.len_low = 0u32;
st.len_high = 0u32;
@@ -260,7 +260,7 @@ fn mk_sha1() -> sha1 {
}
fn input_str(&str msg) {
- add_input(st, Str.bytes(msg));
+ add_input(st, _str::bytes(msg));
}
fn result() -> vec[u8] {
@@ -271,19 +271,19 @@ fn mk_sha1() -> sha1 {
auto r = mk_result(st);
auto s = "";
for (u8 b in r) {
- s += UInt.to_str(b as uint, 16u);
+ s += _uint::to_str(b as uint, 16u);
}
ret s;
}
}
- auto st = rec(h = Vec.init_elt_mut[u32](0u32, digest_buf_len),
+ auto st = rec(h = _vec::init_elt_mut[u32](0u32, digest_buf_len),
mutable len_low = 0u32,
mutable len_high = 0u32,
- msg_block = Vec.init_elt_mut[u8](0u8, msg_block_len),
+ msg_block = _vec::init_elt_mut[u8](0u8, msg_block_len),
mutable msg_block_idx = 0u,
mutable computed = false,
- work_buf = Vec.init_elt_mut[u32](0u32, work_buf_len));
+ work_buf = _vec::init_elt_mut[u32](0u32, work_buf_len));
auto sh = sha1(st);
sh.reset();
ret sh;
diff --git a/src/lib/Sort.rs b/src/lib/sort.rs
index 7ecaaaba..3b3c6403 100644
--- a/src/lib/Sort.rs
+++ b/src/lib/sort.rs
@@ -1,5 +1,5 @@
-import Vec.len;
-import Vec.slice;
+import _vec::len;
+import _vec::slice;
type lteq[T] = fn(&T a, &T b) -> bool;
diff --git a/src/lib/std.rc b/src/lib/std.rc
index a317b114..5c0ea313 100644
--- a/src/lib/std.rc
+++ b/src/lib/std.rc
@@ -6,76 +6,76 @@ meta (name = "std",
// Built-in types support modules.
-mod Int;
-mod UInt;
-mod U8;
-mod Vec;
-mod Str;
+mod _int;
+mod _uint;
+mod _u8;
+mod _vec;
+mod _str;
-// General IO and system-services modules.
+// General io and system-services modules.
-mod IO;
-mod Sys;
-mod Task;
+mod io;
+mod sys;
+mod _task;
// Utility modules.
-mod Option;
-mod Util;
+mod option;
+mod util;
// Authorize various rule-bendings.
-auth IO = unsafe;
-auth FS = unsafe;
-auth OS_FS = unsafe;
-auth Run = unsafe;
-auth Str = unsafe;
-auth Vec = unsafe;
-auth Task = unsafe;
+auth io = unsafe;
+auth fs = unsafe;
+auth os_fs = unsafe;
+auth run = unsafe;
+auth _str = unsafe;
+auth _vec = unsafe;
+auth _task = unsafe;
-auth Dbg = unsafe;
+auth dbg = unsafe;
-auth UInt.next_power_of_two = unsafe;
-auth Map.mk_hashmap = unsafe;
-auth Rand.mk_rng = unsafe;
+auth _uint::next_power_of_two = unsafe;
+auth map::mk_hashmap = unsafe;
+auth rand::mk_rng = unsafe;
-// Target-OS module.
+// Target-os module.
-// TODO: Have each OS module re-export everything from GenericOS.
-mod GenericOS;
+// TODO: Have each os module re-export everything from genericos.
+mod generic_os;
alt (target_os) {
case ("win32") {
- mod OS = "win32_OS.rs";
- mod OS_FS = "win32_FS.rs";
+ mod os = "win32_os.rs";
+ mod os_fs = "win32_fs.rs";
} case ("macos") {
- mod OS = "macos_OS.rs";
- mod OS_FS = "posix_FS.rs";
+ mod os = "macos_os.rs";
+ mod os_fs = "posix_fs.rs";
} else {
- mod OS = "linux_OS.rs";
- mod OS_FS = "posix_FS.rs";
+ mod os = "linux_os.rs";
+ mod os_fs = "posix_fs.rs";
}
}
-mod Run = "Run_Program.rs";
-mod FS;
+mod run = "run_program.rs";
+mod fs;
// FIXME: parametric
-mod Map;
-mod Deque;
-mod List;
-mod Rand;
-mod Dbg;
-mod BitV;
-mod Sort;
-mod SHA1;
-mod EBML;
-mod UFind;
-mod ExtFmt;
-mod Box;
-mod GetOpts;
-mod Term;
-mod Time;
+mod map;
+mod deque;
+mod list;
+mod rand;
+mod dbg;
+mod bitv;
+mod sort;
+mod sha1;
+mod ebml;
+mod ufind;
+mod extfmt;
+mod box;
+mod getopts;
+mod term;
+mod time;
// Local Variables:
// mode: rust;
diff --git a/src/lib/Sys.rs b/src/lib/sys.rs
index 77eab003..77eab003 100644
--- a/src/lib/Sys.rs
+++ b/src/lib/sys.rs
diff --git a/src/lib/Term.rs b/src/lib/term.rs
index b07dcc0c..6fd54a2d 100644
--- a/src/lib/Term.rs
+++ b/src/lib/term.rs
@@ -21,20 +21,20 @@ const u8 color_bright_magenta = 13u8;
const u8 color_bright_cyan = 14u8;
const u8 color_bright_white = 15u8;
-fn esc(IO.buf_writer writer) {
+fn esc(io::buf_writer writer) {
writer.write(vec(0x1bu8, '[' as u8));
}
-fn reset(IO.buf_writer writer) {
+fn reset(io::buf_writer writer) {
esc(writer);
writer.write(vec('0' as u8, 'm' as u8));
}
fn color_supported() -> bool {
- ret GenericOS.getenv("TERM") == Option.some[str]("xterm-color");
+ ret generic_os::getenv("TERM") == option::some[str]("xterm-color");
}
-fn set_color(IO.buf_writer writer, u8 first_char, u8 color) {
+fn set_color(io::buf_writer writer, u8 first_char, u8 color) {
assert (color < 16u8);
esc(writer);
@@ -45,11 +45,11 @@ fn set_color(IO.buf_writer writer, u8 first_char, u8 color) {
writer.write(vec(first_char, ('0' as u8) + color, 'm' as u8));
}
-fn fg(IO.buf_writer writer, u8 color) {
+fn fg(io::buf_writer writer, u8 color) {
ret set_color(writer, '3' as u8, color);
}
-fn bg(IO.buf_writer writer, u8 color) {
+fn bg(io::buf_writer writer, u8 color) {
ret set_color(writer, '4' as u8, color);
}
diff --git a/src/lib/Time.rs b/src/lib/time.rs
index 70a12a6f..645d19ac 100644
--- a/src/lib/Time.rs
+++ b/src/lib/time.rs
@@ -6,7 +6,7 @@ type timeval = rec(u32 sec, u32 usec);
fn get_time() -> timeval {
let timeval res = rec(sec=0u32, usec=0u32);
- rustrt.get_time(res.sec, res.usec);
+ rustrt::get_time(res.sec, res.usec);
ret res;
}
diff --git a/src/lib/UFind.rs b/src/lib/ufind.rs
index 0bb06d7c..faa77305 100644
--- a/src/lib/UFind.rs
+++ b/src/lib/ufind.rs
@@ -1,19 +1,19 @@
-import Option.none;
-import Option.some;
+import option::none;
+import option::some;
// A very naive implementation of union-find with unsigned integer nodes.
-type node = Option.t[uint];
+type node = option::t[uint];
type ufind = rec(mutable vec[mutable node] nodes);
fn make() -> ufind {
let vec[mutable node] v = vec(mutable none[uint]);
- Vec.pop(v); // FIXME: botch
+ _vec::pop(v); // FIXME: botch
ret rec(mutable nodes=v);
}
fn make_set(&ufind ufnd) -> uint {
- auto idx = Vec.len(ufnd.nodes);
+ auto idx = _vec::len(ufnd.nodes);
ufnd.nodes += vec(mutable none[uint]);
ret idx;
}
diff --git a/src/lib/Util.rs b/src/lib/util.rs
index a385aafd..b8d8ed65 100644
--- a/src/lib/Util.rs
+++ b/src/lib/util.rs
@@ -4,10 +4,10 @@ fn id[T](&T x) -> T {
/* FIXME (issue #141): See test/run-pass/constrained-type.rs. Uncomment
* the constraint once fixed. */
-type rational = rec(int num, int den); // : Int.positive(*.den);
+type rational = rec(int num, int den); // : _int::positive(*.den);
fn rational_leq(&rational x, &rational y) -> bool {
- // NB: Uses the fact that rationals have positive denominators WLOG.
+ // NB: Uses the fact that rationals have positive denominators WLOG:
ret x.num * y.den <= y.num * x.den;
}
diff --git a/src/lib/win32_FS.rs b/src/lib/win32_fs.rs
index 94599e3c..3e2c4f67 100644
--- a/src/lib/win32_FS.rs
+++ b/src/lib/win32_fs.rs
@@ -4,7 +4,7 @@ native "rust" mod rustrt {
}
fn list_dir(str path) -> vec[str] {
- ret rustrt.rust_list_files(path+"*");
+ ret rustrt::rust_list_files(path+"*");
}
/* FIXME: win32 path handling actually accepts '/' or '\' and has subtly
diff --git a/src/lib/win32_OS.rs b/src/lib/win32_os.rs
index 7330102e..e9555249 100644
--- a/src/lib/win32_OS.rs
+++ b/src/lib/win32_os.rs
@@ -1,5 +1,5 @@
-import Str.sbuf;
-import Vec.vbuf;
+import _str::sbuf;
+import _vec::vbuf;
native mod libc = "msvcrt.dll" {
fn open(sbuf s, int flags, uint mode) -> int = "_open";
@@ -53,13 +53,13 @@ fn dylib_filename(str base) -> str {
fn pipe() -> tup(int, int) {
let vec[mutable int] fds = vec(mutable 0, 0);
- assert (OS.libc._pipe(Vec.buf(fds), 1024u,
- libc_constants.O_BINARY()) == 0);
+ assert (os::libc::_pipe(_vec::buf(fds), 1024u,
+ libc_constants::O_BINARY()) == 0);
ret tup(fds.(0), fds.(1));
}
-fn fd_FILE(int fd) -> libc.FILE {
- ret libc._fdopen(fd, Str.buf("r"));
+fn fd_FILE(int fd) -> libc::FILE {
+ ret libc::_fdopen(fd, _str::buf("r"));
}
native "rust" mod rustrt {
@@ -67,7 +67,7 @@ native "rust" mod rustrt {
}
fn waitpid(int pid) -> int {
- ret rustrt.rust_process_wait(pid);
+ ret rustrt::rust_process_wait(pid);
}
// Local Variables: