diff options
| author | Tim Chevalier <[email protected]> | 2011-04-07 18:15:56 -0700 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2011-04-08 17:46:46 +0000 |
| commit | 9c001af07c658b9583bde8d138d1d9408274d741 (patch) | |
| tree | adbc1327204422bfbd3c30e36e951a01d7df0c6d /src/comp/util/common.rs | |
| parent | Disable effect checking in rustboot (diff) | |
| download | rust-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/comp/util/common.rs')
| -rw-r--r-- | src/comp/util/common.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/comp/util/common.rs b/src/comp/util/common.rs index 5243e2f7..6dec6c00 100644 --- a/src/comp/util/common.rs +++ b/src/comp/util/common.rs @@ -1,5 +1,6 @@ import std._uint; import std._int; +import std._vec; import front.ast; @@ -75,6 +76,17 @@ fn istr(int i) -> str { ret _int.to_str(i, 10u); } +fn uistr(uint i) -> str { + ret _uint.to_str(i, 10u); +} + +fn elt_expr(&ast.elt e) -> @ast.expr { ret e.expr; } + +fn elt_exprs(vec[ast.elt] elts) -> vec[@ast.expr] { + auto f = elt_expr; + be _vec.map[ast.elt, @ast.expr](f, elts); +} + // // Local Variables: // mode: rust |