aboutsummaryrefslogtreecommitdiff
path: root/src/lib/bitv.rs
diff options
context:
space:
mode:
authorGraydon Hoare <[email protected]>2010-11-02 15:24:46 -0700
committerGraydon Hoare <[email protected]>2010-11-02 15:24:46 -0700
commit7db115834f24eb9d9ccbd2468c9145fdf86be514 (patch)
tree5e5e1463ba1201524c6d10690c0982f4b168ba9f /src/lib/bitv.rs
parentFirst pass on splitting stratum and opacity off of effects. WIP. (diff)
downloadrust-7db115834f24eb9d9ccbd2468c9145fdf86be514.tar.xz
rust-7db115834f24eb9d9ccbd2468c9145fdf86be514.zip
Split out stratum-checking pass, implement more-strict (overly aggressive) impure-effect checking.
Diffstat (limited to 'src/lib/bitv.rs')
-rw-r--r--src/lib/bitv.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/lib/bitv.rs b/src/lib/bitv.rs
index af90060a..2a8c7d0e 100644
--- a/src/lib/bitv.rs
+++ b/src/lib/bitv.rs
@@ -29,7 +29,7 @@ fn create(uint nbits, bool init) -> t {
ret rec(storage = storage, nbits = nbits);
}
-fn process(&fn(uint, uint) -> uint op, &t v0, &t v1) -> bool {
+impure 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);
@@ -55,7 +55,7 @@ fn lor(uint w0, uint w1) -> uint {
ret w0 | w1;
}
-fn union(&t v0, &t v1) -> bool {
+impure fn union(&t v0, &t v1) -> bool {
auto sub = lor;
ret process(sub, v0, v1);
}
@@ -64,7 +64,7 @@ fn land(uint w0, uint w1) -> uint {
ret w0 & w1;
}
-fn intersect(&t v0, &t v1) -> bool {
+impure fn intersect(&t v0, &t v1) -> bool {
auto sub = land;
ret process(sub, v0, v1);
}
@@ -73,7 +73,7 @@ fn right(uint w0, uint w1) -> uint {
ret w1;
}
-fn copy(&t v0, t v1) -> bool {
+impure fn copy(&t v0, t v1) -> bool {
auto sub = right;
ret process(sub, v0, v1);
}
@@ -103,27 +103,27 @@ fn equal(&t v0, &t v1) -> bool {
ret true;
}
-fn clear(&t v) {
+impure fn clear(&t v) {
for each (uint i in _uint.range(0u, _vec.len[mutable uint](v.storage))) {
v.storage.(i) = 0u;
}
}
-fn invert(&t v) {
+impure 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 */
-fn difference(&t v0, &t v1) -> bool {
+impure fn difference(&t v0, &t v1) -> bool {
invert(v1);
auto b = intersect(v0, v1);
invert(v1);
ret b;
}
-fn set(&t v, uint i, bool x) {
+impure fn set(&t v, uint i, bool x) {
check (i < v.nbits);
auto bits = uint_bits();
@@ -175,6 +175,6 @@ fn eq_vec(&t v0, &vec[uint] v1) -> bool {
// indent-tabs-mode: nil
// c-basic-offset: 4
// buffer-file-coding-system: utf-8-unix
-// compile-command: "make -k -C ../.. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
+// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
// End:
//