From 7db115834f24eb9d9ccbd2468c9145fdf86be514 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Tue, 2 Nov 2010 15:24:46 -0700 Subject: Split out stratum-checking pass, implement more-strict (overly aggressive) impure-effect checking. --- src/lib/bitv.rs | 18 +++++++++--------- src/lib/map.rs | 20 ++++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) (limited to 'src/lib') 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: // diff --git a/src/lib/map.rs b/src/lib/map.rs index 4d7a6c03..2693441b 100644 --- a/src/lib/map.rs +++ b/src/lib/map.rs @@ -70,12 +70,12 @@ 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. */ - fn insert_common[K, V](&hashfn[K] hasher, - &eqfn[K] eqer, - vec[mutable bucket[K, V]] bkts, - uint nbkts, - &K key, - &V val) + impure fn insert_common[K, V](&hashfn[K] hasher, + &eqfn[K] eqer, + vec[mutable bucket[K, V]] bkts, + uint nbkts, + &K key, + &V val) -> bool { let uint i = 0u; @@ -125,10 +125,10 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] { } - 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) + impure 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) { for (bucket[K, V] b in oldbkts) { alt (b) { -- cgit v1.2.3