diff options
| author | Tim Chevalier <chevalier@alum.wellesley.edu> | 2011-06-22 21:26:34 -0700 |
|---|---|---|
| committer | Tim Chevalier <chevalier@alum.wellesley.edu> | 2011-06-22 22:13:42 -0700 |
| commit | 9a48bd2f2133a76371cb92488620146be990a82c (patch) | |
| tree | 4664e8f3de63d83e5497e857a7a0f27bc24b3625 /src/comp/util | |
| parent | 7105cd1761c9ad84f95381f021ca4960e2bd0641 (diff) | |
| download | rust-9a48bd2f2133a76371cb92488620146be990a82c.tar.gz rust-9a48bd2f2133a76371cb92488620146be990a82c.zip | |
Compute typestate properly for move
typestate now drops constraints correctly in the post-state of a move expression or a declaration whose op is a move. It doesn't yet drop constraints mentioning variables that get updated. To do this, I had to change typestate to use trit-vectors instead of bit-vectors, because for every constraint, there are three possible values: known-to-be-false (e.g. after x <- y, init(y) is known-to-be-false), known-to-be-true, and unknown. Before, we conflated known-to-be-false with unknown. But move requires them to be treated differently. Consider: (program a) (a1) x = 1; (a2) y <- x; (a3) log x; (program b) (b1) x = 1; (b2) y <- z; (b3) log x; With only two values, the postcondition of statement a2 for constraint init(x) is the same as that of b2: 0. But in (a2)'s postcondition, init(x) *must* be false, but in (b2)'s condition, it's just whatever it was in the postcondition of the preceding statement.
Diffstat (limited to 'src/comp/util')
| -rw-r--r-- | src/comp/util/common.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/comp/util/common.rs b/src/comp/util/common.rs index 801dda99de4..87a1908f8e0 100644 --- a/src/comp/util/common.rs +++ b/src/comp/util/common.rs @@ -252,6 +252,15 @@ fn is_hex_digit(char c) -> bool { } fn is_bin_digit(char c) -> bool { ret c == '0' || c == '1'; } + +// FIXME move to vec +fn any[T](&fn(&T) -> bool f, &vec[T] v) -> bool { + for (T t in v) { + if (f(t)) { ret true; } + } + ret false; +} + // // Local Variables: // mode: rust |
