aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorTim Chevalier <[email protected]>2011-04-07 18:15:56 -0700
committerGraydon Hoare <[email protected]>2011-04-08 17:46:46 +0000
commit9c001af07c658b9583bde8d138d1d9408274d741 (patch)
treeadbc1327204422bfbd3c30e36e951a01d7df0c6d /src/lib
parentDisable effect checking in rustboot (diff)
downloadrust-9c001af07c658b9583bde8d138d1d9408274d741.tar.xz
rust-9c001af07c658b9583bde8d138d1d9408274d741.zip
Implemented computing prestates and poststates for a few expression forms.
The typestate checker (if it's uncommented) now correctly rejects a trivial example program that has an uninitialized variable.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/bitv.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/lib/bitv.rs b/src/lib/bitv.rs
index 98e6c040..75254ce7 100644
--- a/src/lib/bitv.rs
+++ b/src/lib/bitv.rs
@@ -170,6 +170,21 @@ fn to_vec(&t v) -> vec[uint] {
ret _vec.init_fn[uint](sub, v.nbits);
}
+fn to_str(&t v) -> str {
+ auto res = "";
+
+ for(uint i in v.storage) {
+ if (i == 1u) {
+ res += "1";
+ }
+ else {
+ res += "0";
+ }
+ }
+
+ ret res;
+}
+
// FIXME: can we just use structural equality on to_vec?
fn eq_vec(&t v0, &vec[uint] v1) -> bool {
check (v0.nbits == _vec.len[uint](v1));