about summary refs log tree commit diff
path: root/src/lib
diff options
context:
space:
mode:
authorTim Chevalier <chevalier@alum.wellesley.edu>2011-04-20 12:11:01 -0700
committerGraydon Hoare <graydon@mozilla.com>2011-04-28 13:26:19 -0700
commit7c4f8cb45924326e21547d19cbed683115657616 (patch)
tree9b27e94ec87c7bec6f1e4bd4e15c742d7d241d7e /src/lib
parentb0980b7d79e8209ba91a2a85c720f238bbc478ed (diff)
Further work on typestate_check
Lots of work on typestate_check, seems to get a lot of the way
through checking the standard library.

* Added for, for_each, assign_op, bind, cast, put, check, break,
and cont. (I'm not sure break and cont are actually handled correctly.)

* Fixed side-effect bug in seq_preconds so that unioning the
preconditions of a sequence of statements or expressions
is handled correctly.

* Pass poststate correctly through a stmt_decl.

* Handle expr_ret and expr_fail properly (after execution of a ret
or fail, everything is true -- this is needed to handle ifs and alts
where one branch is a ret or fail)

* Fixed bug in set_prestate_ann where a thing that needed to be
mutated wasn't getting passed as an alias

* Fixed bug in how expr_alt was treated (zero is not the identity
for intersect, who knew, right?)

* Update logging to reflect log_err vs. log

* Fixed find_locals so as to return all local decls and exclude
function arguments.

* Make union_postconds work on an empty vector (needed to handle
empty blocks correctly)

* Added _vec.cat_options, which takes a list of option[T] to a list
of T, ignoring any Nones

* Added two test cases.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/_vec.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/lib/_vec.rs b/src/lib/_vec.rs
index ab222be913f..3718ac357e0 100644
--- a/src/lib/_vec.rs
+++ b/src/lib/_vec.rs
@@ -282,6 +282,21 @@ fn plus_option[T](&vec[T] v, &option.t[T] o) -> () {
     }
 }
 
+fn cat_options[T](&vec[option.t[T]] v) -> vec[T] {
+    let vec[T] res = vec();
+
+    for (option.t[T] o in v) {
+        alt (o) {
+            case (none[T]) { }
+            case (some[T](?t)) {
+                res += vec(t);
+            }
+        }
+    }
+
+    ret res;
+}
+
 // TODO: Remove in favor of built-in "freeze" operation when it's implemented.
 fn freeze[T](vec[mutable T] v) -> vec[T] {
     let vec[T] result = vec();