Commit graph

35 commits

Author SHA1 Message Date
Tim Chevalier
b7dd75c904 Handle nested items correctly in typestate_check
Summary says it all. Actually, only nested objects and functions
are handled, but that's better than before. The fold that I was using
before to traverse a crate wasn't working correctly, because annotations
have to reflect the number of local variables of the nearest enclosing
function (in turn, because annotations are represented as bit vectors).
The fold was traversing the AST in the wrong order, first filling in
the annotations correctly, but then re-traversing them with the bit
vector length for any outer nested functions, and so on.

Remedying this required writing a lot of tedious boilerplate code
because I scrapped the idea of using a fold altogether.

I also made typestate_check handle unary, field, alt, and fail.

Also, some miscellaneous changes:
* added annotations to blocks in typeck
* fix pprust so it can handle spawn
* added more logging functions in util.common
* fixed _vec.or
* added maybe and from_maybe in option
* removed fold_block field from ast_fold, since it was never used
2011-04-19 14:56:28 -07:00
Graydon Hoare
d2bd07dcb0 Remove effect system from src. 2011-04-19 13:35:49 -07:00
Patrick Walton
3e922e2ecf stdlib: Add some vector functions: empty, empty_mut, grow_set, and freeze. Change _vec.grow to use uint arguments. 2011-04-15 17:46:16 -07:00
Tim Chevalier
7c6e6fc5d4 Make expr_while work in typestate_check
Also did some refactoring in typestate_check. All test cases in
compile-fail that involve uninitialized vars now fail correctly!
(All eight of them, that is.)
2011-04-13 15:50:34 -07:00
Tim Chevalier
2e90bd94de Continued sketching out code for checking states against preconditions.
It's still sketchy. I added a typestate annotation field to statements
tagged stmt_decl or stmt_expr, because a stmt_decl statement has a typestate
that's different from that of its child node. This necessitated trivial
changes to a bunch of other files all over to the compiler. I also added a
few small standard library functions, some of which I didn't actually end
up using but which I thought might be useful anyway.
2011-04-06 17:58:18 -07:00
Tim Chevalier
3130348ee1 Started adding support for typestate checking.
I added a new field to the ast "ann" type for typestate information.
Currently, the field contains a record of a precondition bit vector and
postcondition vector, but I tried to structure things so as to make
it easy to change the representation of the typestate annotation type.
I also had to add annotations to some syntactic forms that didn't have
them before (fail, ret, be...), with all the boilerplate changes
that that would imply.

The main call to the typestate_check entry point is commented out and
the actual pre-postcondition algorithm only has a few cases
implemented, though the overall AST traversal is there. The rest of
the typestate algorithm isn't implemented yet.
2011-04-01 11:27:32 -07:00
Patrick Walton
af3d0d1848 rustc: Open "use"d crates; add a _vec.vec_from_buf() method along the way; XFAIL use-import-export.rs in rustc 2011-03-24 17:22:07 -07:00
Patrick Walton
e56a1720e4 Add a "last" function to return the last element of a vector to the standard library 2011-03-21 17:21:35 -07:00
Patrick Walton
0cf16e77ca Add "mutable?" to _vec in the standard library; fix callers 2011-03-18 14:01:03 -07:00
Patrick Walton
368eb4bab6 Add some mutable variants of vector functions to the standard library 2011-03-18 13:53:49 -07:00
Graydon Hoare
54587bdccb Switch all vases of vec += elt to vec += vec. Prohibit former in rustboot. Tweak std lib vec fns in process. 2011-03-16 14:58:02 -07:00
Graydon Hoare
11a10c7a7b Remove redundant imports in lib (rustc doesn't like 'std' as a synonym for root within std.rc anyway) 2011-03-09 17:29:18 -08:00
Patrick Walton
3e482d5f69 Implement a map2() function in std._vec 2010-11-09 15:38:42 -08:00
Graydon Hoare
89946609f2 Support a special const-value refcount, use it for const strings. 2010-11-09 14:15:07 -08:00
Patrick Walton
adb1754e4d Move the option type to its own module 2010-11-05 11:18:40 -07:00
Graydon Hoare
05c9d885dd Change vec slice to use uint, add push/pop/shift/unshift. 2010-10-22 11:46:04 -07:00
Graydon Hoare
2880ecd73f Reformat standard library; no code changes. 2010-09-22 15:44:13 -07:00
Roy Frostig
974092c526 Test multi-ref'ed vec growth more seriously than before. 2010-09-03 16:25:56 -07:00
Roy Frostig
4a7aa75b5d Make _io.buf_reader read more than 0 bytes at a time. 2010-08-19 17:37:22 -07:00
Roy Frostig
6bce296d9f Address FIXME in _vec waiting on closed issue #108. 2010-08-12 13:18:10 -07:00
Roy Frostig
445d3fe39c Add vec debugging utility to _vec module. 2010-08-12 13:11:49 -07:00
Roy Frostig
8e02a2bcb5 Fix reverse-indexing bug in _vec.init_fn. 2010-08-11 15:56:19 -07:00
Roy Frostig
1a8d609e89 Add a buffered writer to stdlib _io module. 2010-08-04 12:59:48 -07:00
Roy Frostig
5b2451c231 Address _vec.map allocation FIXME. Add test. 2010-08-03 18:18:19 -07:00
Roy Frostig
5796ebb1e7 Address _vec.grow FIXME, as issue #89 has been closed. 2010-08-03 18:10:18 -07:00
Roy Frostig
d5fd81174e Pass parametric types by-alias in various stdlib spots. 2010-08-03 18:06:31 -07:00
Graydon Hoare
8030757624 Switch machine-type lexemes to use suffixes. Remove support for foo(bar) as a cast notation. Closes #129. 2010-07-27 19:21:51 -07:00
Roy Frostig
1730d2e037 Notify copy glue of dst-initialization and fix _vec.alloc issues in lib and runtime. Closes #109. 2010-07-22 17:47:32 -07:00
Roy Frostig
1ae13b3fdd Source FIXME annotations for issue #81 and a correction to STMT_bind fmt. 2010-07-22 12:45:58 -07:00
Patrick Walton
c96f0bf738 Implement the "simple typechecker", which avoids HM inference 2010-07-15 18:27:09 -07:00
Jeffrey Yasskin
765a2b3ecf Add a _vec.slice function that'll hold us over until .(a,b) syntax is
implemented.  This could actually replace .(a,b) syntax if the language grows
optional function parameters.
2010-07-16 08:13:08 +08:00
Graydon Hoare
40d6aacb82 Add differently-typed refcount synonyms to _str and _vec. 2010-07-13 14:23:49 -07:00
Graydon Hoare
f360d222c8 Uint-ify various bits of _str and _vec, enrich _vec a bit. 2010-07-05 14:42:12 -07:00
Roy Frostig
023e5af639 The few and proud isolated bits from stdlib-work so far that don't break everything. Note util.rs hasn't yet been declared mod in the std crate. Don't do that yet, as it breaks make check. 2010-06-28 23:18:51 -07:00
Graydon Hoare
d6b7c96c3e Populate tree. 2010-06-23 21:03:09 -07:00