about summary refs log tree commit diff
path: root/src/lib
diff options
context:
space:
mode:
authorGraydon Hoare <graydon@mozilla.com>2011-04-19 13:35:49 -0700
committerGraydon Hoare <graydon@mozilla.com>2011-04-19 13:35:49 -0700
commitd2bd07dcb02783063375b6c8532fceaf9fa9d50f (patch)
treea253b5eadb140d14bc99d1456e316ce1e210a6be /src/lib
parentd9d5eb82a7af56c60fe09aff5d73a2fb525d7f57 (diff)
Remove effect system from src.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/_str.rs4
-rw-r--r--src/lib/_vec.rs2
-rw-r--r--src/lib/bitv.rs16
-rw-r--r--src/lib/fs.rs4
-rw-r--r--src/lib/io.rs128
-rw-r--r--src/lib/map.rs4
-rw-r--r--src/lib/posix_fs.rs2
-rw-r--r--src/lib/run_program.rs14
-rw-r--r--src/lib/sha1.rs8
-rw-r--r--src/lib/std.rc15
-rw-r--r--src/lib/win32_fs.rs2
11 files changed, 92 insertions, 107 deletions
diff --git a/src/lib/_str.rs b/src/lib/_str.rs
index 7690fe44a50..3922acb6a92 100644
--- a/src/lib/_str.rs
+++ b/src/lib/_str.rs
@@ -154,11 +154,11 @@ fn unsafe_from_byte(u8 u) -> str {
     ret rustrt.str_from_vec(vec(u));
 }
 
-unsafe fn str_from_cstr(sbuf cstr) -> str {
+fn str_from_cstr(sbuf cstr) -> str {
     ret rustrt.str_from_cstr(cstr);
 }
 
-unsafe fn str_from_buf(sbuf buf, uint len) -> str {
+fn str_from_buf(sbuf buf, uint len) -> str {
     ret rustrt.str_from_buf(buf, len);
 }
 
diff --git a/src/lib/_vec.rs b/src/lib/_vec.rs
index ac2ffc8bcf8..6fc1d700886 100644
--- a/src/lib/_vec.rs
+++ b/src/lib/_vec.rs
@@ -51,7 +51,7 @@ fn refcount[T](vec[mutable? T] v) -> uint {
     }
 }
 
-unsafe fn vec_from_vbuf[T](vbuf v, uint n_elts) -> vec[T] {
+fn vec_from_vbuf[T](vbuf v, uint n_elts) -> vec[T] {
     ret rustrt.vec_from_vbuf[T](v, n_elts);
 }
 
diff --git a/src/lib/bitv.rs b/src/lib/bitv.rs
index fab40ac8332..feb4296aa6e 100644
--- a/src/lib/bitv.rs
+++ b/src/lib/bitv.rs
@@ -25,7 +25,7 @@ fn create(uint nbits, bool init) -> t {
     ret rec(storage = storage, nbits = nbits);
 }
 
-impure fn process(&fn(uint, uint) -> uint op, &t v0, &t v1) -> bool {
+fn process(&fn(uint, uint) -> uint op, &t v0, &t v1) -> bool {
     auto len = _vec.len[mutable uint](v1.storage);
 
     check (_vec.len[mutable uint](v0.storage) == len);
@@ -51,7 +51,7 @@ fn lor(uint w0, uint w1) -> uint {
     ret w0 | w1;
 }
 
-impure fn union(&t v0, &t v1) -> bool {
+fn union(&t v0, &t v1) -> bool {
     auto sub = lor;
     ret process(sub, v0, v1);
 }
@@ -60,7 +60,7 @@ fn land(uint w0, uint w1) -> uint {
     ret w0 & w1;
 }
 
-impure fn intersect(&t v0, &t v1) -> bool {
+fn intersect(&t v0, &t v1) -> bool {
     auto sub = land;
     ret process(sub, v0, v1);
 }
@@ -69,7 +69,7 @@ fn right(uint w0, uint w1) -> uint {
     ret w1;
 }
 
-impure fn copy(&t v0, t v1) -> bool {
+fn copy(&t v0, t v1) -> bool {
     auto sub = right;
     ret process(sub, v0, v1);
 }
@@ -108,27 +108,27 @@ fn equal(&t v0, &t v1) -> bool {
     ret true;
 }
 
-impure fn clear(&t v) {
+fn clear(&t v) {
     for each (uint i in _uint.range(0u, _vec.len[mutable uint](v.storage))) {
         v.storage.(i) = 0u;
     }
 }
 
-impure fn invert(&t v) {
+fn invert(&t v) {
     for each (uint i in _uint.range(0u, _vec.len[mutable uint](v.storage))) {
         v.storage.(i) = ~v.storage.(i);
     }
 }
 
 /* v0 = v0 - v1 */
-impure fn difference(&t v0, &t v1) -> bool {
+fn difference(&t v0, &t v1) -> bool {
     invert(v1);
     auto b = intersect(v0, v1);
     invert(v1);
     ret b;
 }
 
-impure fn set(&t v, uint i, bool x) {
+fn set(&t v, uint i, bool x) {
     check (i < v.nbits);
 
     auto bits = uint_bits();
diff --git a/src/lib/fs.rs b/src/lib/fs.rs
index 5bced0ba071..774ce11324c 100644
--- a/src/lib/fs.rs
+++ b/src/lib/fs.rs
@@ -26,11 +26,11 @@ fn connect(path pre, path post) -> path {
     ret pre + path_sep() + post;
 }
 
-impure fn file_is_dir(path p) -> bool {
+fn file_is_dir(path p) -> bool {
   ret rustrt.rust_file_is_dir(p) != 0;
 }
 
-impure fn list_dir(path p) -> vec[str] {
+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) {
     p += path_sep();
diff --git a/src/lib/io.rs b/src/lib/io.rs
index c3ebd0fc078..2c2c0dbf539 100644
--- a/src/lib/io.rs
+++ b/src/lib/io.rs
@@ -14,37 +14,37 @@ tag seek_style {seek_set; seek_end; seek_cur;}
 // The raw underlying reader class. All readers must implement this.
 type buf_reader =
     state obj {
-        impure fn read(uint len) -> vec[u8];
-        impure fn read_byte() -> int;
-        impure fn unread_byte(int byte);
-        impure fn eof() -> bool;
+        fn read(uint len) -> vec[u8];
+        fn read_byte() -> int;
+        fn unread_byte(int byte);
+        fn eof() -> bool;
 
         // FIXME: Seekable really should be orthogonal. We will need
         // inheritance.
-        impure fn seek(int offset, seek_style whence);
-        impure fn tell() -> uint;
+        fn seek(int offset, seek_style whence);
+        fn tell() -> uint;
     };
 
 // Convenience methods for reading.
 type reader =
     state obj {
           // FIXME: This should inherit from buf_reader.
-          impure fn get_buf_reader() -> buf_reader;
-
-          impure fn read_byte() -> int;
-          impure fn unread_byte(int byte);
-          impure fn read_bytes(uint len) -> vec[u8];
-          impure fn read_char() -> char;
-          impure fn eof() -> bool;
-          impure fn read_line() -> str;
-          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 read_whole_stream() -> vec[u8];
-
-          impure fn seek(int offset, seek_style whence);
-          impure fn tell() -> uint; // FIXME: eventually u64
+          fn get_buf_reader() -> buf_reader;
+
+          fn read_byte() -> int;
+          fn unread_byte(int byte);
+          fn read_bytes(uint len) -> vec[u8];
+          fn read_char() -> char;
+          fn eof() -> bool;
+          fn read_line() -> str;
+          fn read_c_str() -> str;
+          fn read_le_uint(uint size) -> uint;
+          fn read_le_int(uint size) -> int;
+          fn read_be_uint(uint size) -> uint;
+          fn read_whole_stream() -> vec[u8];
+
+          fn seek(int offset, seek_style whence);
+          fn tell() -> uint; // FIXME: eventually u64
     };
 
 fn convert_whence(seek_style whence) -> int {
@@ -56,25 +56,25 @@ fn convert_whence(seek_style whence) -> int {
 }
 
 state obj FILE_buf_reader(os.libc.FILE f, bool must_close) {
-    impure fn read(uint len) -> vec[u8] {
+    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);
         ret buf;
     }
-    impure fn read_byte() -> int {
+    fn read_byte() -> int {
         ret os.libc.fgetc(f);
     }
-    impure fn unread_byte(int byte) {
+    fn unread_byte(int byte) {
         os.libc.ungetc(byte, f);
     }
-    impure fn eof() -> bool {
+    fn eof() -> bool {
         ret os.libc.feof(f) != 0;
     }
-    impure fn seek(int offset, seek_style whence) {
+    fn seek(int offset, seek_style whence) {
         check (os.libc.fseek(f, offset, convert_whence(whence)) == 0);
     }
-    impure fn tell() -> uint {
+    fn tell() -> uint {
         ret os.libc.ftell(f) as uint;
     }
     drop {
@@ -84,19 +84,19 @@ state obj FILE_buf_reader(os.libc.FILE f, bool must_close) {
 
 // FIXME: Convert this into pseudomethods on buf_reader.
 state obj new_reader(buf_reader rdr) {
-    impure fn get_buf_reader() -> buf_reader {
+    fn get_buf_reader() -> buf_reader {
         ret rdr;
     }
-    impure fn read_byte() -> int {
+    fn read_byte() -> int {
         ret rdr.read_byte();
     }
-    impure fn unread_byte(int byte) {
+    fn unread_byte(int byte) {
         ret rdr.unread_byte(byte);
     }
-    impure fn read_bytes(uint len) -> vec[u8] {
+    fn read_bytes(uint len) -> vec[u8] {
         ret rdr.read(len);
     }
-    impure fn read_char() -> char {
+    fn read_char() -> char {
         auto c0 = rdr.read_byte();
         if (c0 == -1) {ret -1 as char;} // FIXME will this stay valid?
         auto b0 = c0 as u8;
@@ -116,10 +116,10 @@ state obj new_reader(buf_reader rdr) {
         val += ((b0 << ((w + 1u) as u8)) as uint) << ((w - 1u) * 6u - w - 1u);
         ret val as char;
     }
-    impure fn eof() -> bool {
+    fn eof() -> bool {
         ret rdr.eof();
     }
-    impure fn read_line() -> str {
+    fn read_line() -> str {
         let vec[u8] buf = vec();
         // No break yet in rustc
         auto go_on = true;
@@ -130,7 +130,7 @@ state obj new_reader(buf_reader rdr) {
         }
         ret _str.unsafe_from_bytes(buf);
     }
-    impure fn read_c_str() -> str {
+    fn read_c_str() -> str {
         let vec[u8] buf = vec();
         auto go_on = true;
         while (go_on) {
@@ -141,7 +141,7 @@ state obj new_reader(buf_reader rdr) {
         ret _str.unsafe_from_bytes(buf);
     }
     // FIXME deal with eof?
-    impure fn read_le_uint(uint size) -> uint {
+    fn read_le_uint(uint size) -> uint {
         auto val = 0u;
         auto pos = 0u;
         while (size > 0u) {
@@ -151,7 +151,7 @@ state obj new_reader(buf_reader rdr) {
         }
         ret val;
     }
-    impure fn read_le_int(uint size) -> int {
+    fn read_le_int(uint size) -> int {
         auto val = 0u;
         auto pos = 0u;
         while (size > 0u) {
@@ -162,7 +162,7 @@ state obj new_reader(buf_reader rdr) {
         ret val as int;
     }
     // FIXME deal with eof?
-    impure fn read_be_uint(uint size) -> uint {
+    fn read_be_uint(uint size) -> uint {
         auto val = 0u;
         auto sz = size; // FIXME: trans.ml bug workaround
         while (sz > 0u) {
@@ -171,17 +171,17 @@ state obj new_reader(buf_reader rdr) {
         }
         ret val;
     }
-    impure fn read_whole_stream() -> vec[u8] {
+    fn read_whole_stream() -> vec[u8] {
         let vec[u8] buf = vec();
         while (!rdr.eof()) {
             buf += rdr.read(2048u);
         }
         ret buf;
     }
-    impure fn seek(int offset, seek_style whence) {
+    fn seek(int offset, seek_style whence) {
         ret rdr.seek(offset, whence);
     }
-    impure fn tell() -> uint {
+    fn tell() -> uint {
         ret rdr.tell();
     }
 }
@@ -211,7 +211,7 @@ fn new_reader_(buf_reader bufr) -> reader {
 type byte_buf = @rec(vec[u8] buf, mutable uint pos);
 
 state obj byte_buf_reader(byte_buf bbuf) {
-    impure fn read(uint len) -> vec[u8] {
+    fn read(uint len) -> vec[u8] {
         auto rest = _vec.len[u8](bbuf.buf) - bbuf.pos;
         auto to_read = len;
         if (rest < to_read) {
@@ -221,29 +221,29 @@ state obj byte_buf_reader(byte_buf bbuf) {
         bbuf.pos += to_read;
         ret range;
     }
-    impure fn read_byte() -> int {
+    fn read_byte() -> int {
         if (bbuf.pos == _vec.len[u8](bbuf.buf)) {ret -1;}
         auto b = bbuf.buf.(bbuf.pos);
         bbuf.pos += 1u;
         ret b as int;
     }
 
-    impure fn unread_byte(int byte) {
+    fn unread_byte(int byte) {
         log_err "TODO: unread_byte";
         fail;
     }
 
-    impure fn eof() -> bool {
+    fn eof() -> bool {
         ret bbuf.pos == _vec.len[u8](bbuf.buf);
     }
 
-    impure fn seek(int offset, seek_style whence) {
+    fn seek(int offset, seek_style whence) {
         auto pos = bbuf.pos;
         auto len = _vec.len[u8](bbuf.buf);
         bbuf.pos = seek_in_buf(offset, pos, len, whence);
     }
 
-    impure fn tell() -> uint { ret bbuf.pos; }
+    fn tell() -> uint { ret bbuf.pos; }
 }
 
 fn new_byte_buf_reader(vec[u8] buf) -> byte_buf_reader {
@@ -355,14 +355,14 @@ type writer =
           fn get_buf_writer() -> buf_writer;
           // write_str will continue to do utf-8 output only. an alternative
           // function will be provided for general encoded string output
-          impure fn write_str(str s);
-          impure fn write_char(char ch);
-          impure fn write_int(int n);
-          impure fn write_uint(uint n);
-          impure fn write_bytes(vec[u8] bytes);
-          impure fn write_le_uint(uint n, uint size);
-          impure fn write_le_int(int n, uint size);
-          impure fn write_be_uint(uint n, uint size);
+          fn write_str(str s);
+          fn write_char(char ch);
+          fn write_int(int n);
+          fn write_uint(uint n);
+          fn write_bytes(vec[u8] bytes);
+          fn write_le_uint(uint n, uint size);
+          fn write_le_int(int n, uint size);
+          fn write_be_uint(uint n, uint size);
     };
 
 fn uint_to_le_bytes(uint n, uint size) -> vec[u8] {
@@ -389,29 +389,29 @@ state obj new_writer(buf_writer out) {
     fn get_buf_writer() -> buf_writer {
         ret out;
     }
-    impure fn write_str(str s) {
+    fn write_str(str s) {
         out.write(_str.bytes(s));
     }
-    impure fn write_char(char ch) {
+    fn write_char(char ch) {
         // FIXME needlessly consy
         out.write(_str.bytes(_str.from_char(ch)));
     }
-    impure fn write_int(int n) {
+    fn write_int(int n) {
         out.write(_str.bytes(_int.to_str(n, 10u)));
     }
-    impure fn write_uint(uint n) {
+    fn write_uint(uint n) {
         out.write(_str.bytes(_uint.to_str(n, 10u)));
     }
-    impure fn write_bytes(vec[u8] bytes) {
+    fn write_bytes(vec[u8] bytes) {
         out.write(bytes);
     }
-    impure fn write_le_uint(uint n, uint size) {
+    fn write_le_uint(uint n, uint size) {
         out.write(uint_to_le_bytes(n, size));
     }
-    impure fn write_le_int(int n, uint size) {
+    fn write_le_int(int n, uint size) {
         out.write(uint_to_le_bytes(n as uint, size));
     }
-    impure fn write_be_uint(uint n, uint size) {
+    fn write_be_uint(uint n, uint size) {
         out.write(uint_to_be_bytes(n, size));
     }
 }
diff --git a/src/lib/map.rs b/src/lib/map.rs
index f22faaca719..91d0a56a9cc 100644
--- a/src/lib/map.rs
+++ b/src/lib/map.rs
@@ -64,7 +64,7 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] {
      * We attempt to never call this with a full table.  If we do, it
      * will fail.
      */
-    impure fn insert_common[K, V](&hashfn[K] hasher,
+    fn insert_common[K, V](&hashfn[K] hasher,
                                   &eqfn[K] eqer,
                                   vec[mutable bucket[K, V]] bkts,
                                   uint nbkts,
@@ -119,7 +119,7 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] {
         }
 
 
-   impure fn rehash[K, V](&hashfn[K] hasher,
+   fn rehash[K, V](&hashfn[K] hasher,
                           &eqfn[K] eqer,
                           vec[mutable bucket[K, V]] oldbkts, uint noldbkts,
                           vec[mutable bucket[K, V]] newbkts, uint nnewbkts)
diff --git a/src/lib/posix_fs.rs b/src/lib/posix_fs.rs
index 0a37f85d16e..03115fc7d33 100644
--- a/src/lib/posix_fs.rs
+++ b/src/lib/posix_fs.rs
@@ -2,7 +2,7 @@ native "rust" mod rustrt {
   fn rust_dirent_filename(os.libc.dirent ent) -> str;
 }
 
-impure fn list_dir(str path) -> vec[str] {
+fn list_dir(str path) -> vec[str] {
   // TODO ensure this is always closed
   auto dir = os.libc.opendir(_str.buf(path));
   check (dir as uint != 0u);
diff --git a/src/lib/run_program.rs b/src/lib/run_program.rs
index 105d01d591f..31758984f9e 100644
--- a/src/lib/run_program.rs
+++ b/src/lib/run_program.rs
@@ -14,7 +14,7 @@ fn argvec(str prog, vec[str] args) -> vec[sbuf] {
     ret argptrs;
 }
 
-impure fn run_program(str prog, vec[str] args) -> int {
+fn run_program(str prog, vec[str] args) -> int {
     auto pid = rustrt.rust_run_program(_vec.buf[sbuf](argvec(prog, args)),
                                        0, 0, 0);
     ret os.waitpid(pid);
@@ -25,11 +25,11 @@ type program =
         fn get_id() -> int;
         fn input() -> io.writer;
         fn output() -> io.reader;
-        impure fn close_input();
-        impure fn finish() -> int;
+        fn close_input();
+        fn finish() -> int;
     };
 
-impure fn start_program(str prog, vec[str] args) -> @program {
+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
@@ -50,10 +50,10 @@ impure fn start_program(str prog, vec[str] args) -> @program {
         fn output() -> io.reader {
             ret io.new_reader(io.FILE_buf_reader(out_file, false));
         }
-        impure fn close_input() {
+        fn close_input() {
             os.libc.close(in_fd);
         }
-        impure fn finish() -> int {
+        fn finish() -> int {
             if (finished) {ret 0;}
             finished = true;
             os.libc.close(in_fd);
@@ -72,7 +72,7 @@ impure fn start_program(str prog, vec[str] args) -> @program {
                      false);
 }
 
-impure fn program_output(str prog, vec[str] args)
+fn program_output(str prog, vec[str] args)
     -> rec(int status, str out) {
     auto pr = start_program(prog, args);
     pr.close_input();
diff --git a/src/lib/sha1.rs b/src/lib/sha1.rs
index 3899dddbc27..3866be1e04c 100644
--- a/src/lib/sha1.rs
+++ b/src/lib/sha1.rs
@@ -41,7 +41,7 @@ fn mk_sha1() -> sha1 {
                                mutable uint msg_block_idx,
                                mutable bool computed);
 
-    impure fn add_input(&sha1state st, &vec[u8] msg) {
+    fn add_input(&sha1state st, &vec[u8] msg) {
         // FIXME: Should be typestate precondition
         check (!st.computed);
 
@@ -64,7 +64,7 @@ fn mk_sha1() -> sha1 {
         }
     }
 
-    impure fn process_msg_block(&sha1state st) {
+    fn process_msg_block(&sha1state st) {
 
         // FIXME: Make precondition
         check (_vec.len[mutable u32](st.h) == digest_buf_len);
@@ -164,7 +164,7 @@ fn mk_sha1() -> sha1 {
         ret (word << bits_hack) | (word >> (32u32 - bits));
     }
 
-    impure fn mk_result(&sha1state st) -> vec[u8] {
+    fn mk_result(&sha1state st) -> vec[u8] {
         if (!st.computed) {
             pad_msg(st);
             st.computed = true;
@@ -190,7 +190,7 @@ fn mk_sha1() -> sha1 {
      * call process_msg_block() appropriately.  When it returns, it
      * can be assumed that the message digest has been computed.
      */
-    impure fn pad_msg(&sha1state st) {
+    fn pad_msg(&sha1state st) {
         // FIXME: Should be a precondition
         check (_vec.len[mutable u8](st.msg_block) == msg_block_len);
 
diff --git a/src/lib/std.rc b/src/lib/std.rc
index 67a41dad894..7e9e06c2ac9 100644
--- a/src/lib/std.rc
+++ b/src/lib/std.rc
@@ -34,21 +34,6 @@ auth _str = unsafe;
 auth _vec = unsafe;
 auth _task = unsafe;
 
-
-// FIXME: impure on these will infect caller in a way that is totally
-// beyond reason, if the caller's mutated-argument doesn't escape;
-// 'impure' needs work.
-auth _str.unshift_byte = impure;
-auth _str.shift_byte = impure;
-auth _str.pop_byte = impure;
-auth _str.unshift_char = impure;
-auth _str.shift_char = impure;
-auth _str.pop_char = impure;
-auth _vec.shift = impure;
-auth _vec.unshift = impure;
-auth _vec.pop = impure;
-auth UFind.union = impure;
-
 auth dbg = unsafe;
 
 auth _uint.next_power_of_two = unsafe;
diff --git a/src/lib/win32_fs.rs b/src/lib/win32_fs.rs
index 8ad1f1eff13..2d0ea38c603 100644
--- a/src/lib/win32_fs.rs
+++ b/src/lib/win32_fs.rs
@@ -3,7 +3,7 @@ native "rust" mod rustrt {
   fn rust_file_is_dir(str path) -> int;
 }
 
-impure fn list_dir(str path) -> vec[str] {
+fn list_dir(str path) -> vec[str] {
   ret rustrt.rust_list_files(path+"*");
 }