about summary refs log tree commit diff
path: root/src/comp/util/common.rs
AgeCommit message (Collapse)AuthorLines
2011-06-22Compute typestate properly for moveTim Chevalier-0/+9
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.
2011-06-21Move expr ids into the expr record typeMarijn Haverbeke-2/+2
This simplifies the tag variants a bit and makes expr_node_id obsolete.
2011-06-16Consistify ast::local.Paul Stansifer-2/+2
2011-06-16Refactor ast::item representationMarijn Haverbeke-20/+0
Most of the fields in an AST item were present in all variants. Things could be simplified considerably by putting them in the rec rather than in the variant tags.
2011-06-15Reformat source tree (minus a couple tests that are still grumpy).Graydon Hoare-128/+73
2011-06-15rustc: Make room in remaining AST item nodes for attributesBrian Anderson-6/+6
Issue #487
2011-06-15rustc: Make room in item_mod for metadataBrian Anderson-1/+1
Issue #487
2011-06-13Change decl to local in expr_for and expr_for_eachTim Chevalier-1/+1
Since the decl in a for or for-each loop must always be a local decl, I changed the AST to express this. Fewer potential match failures and "the impossible happened" error messages = yay!
2011-06-09rustc: Annotate vector and string literals in the AST with their uniqueness ↵Patrick Walton-2/+4
or lack thereof
2011-06-09Further support for predicate constraintsTim Chevalier-2/+33
Changed function types to include a list of constraints. Added code for parsing and pretty-printing constraints. This necessitated splitting pprust into two files (pprust and ppaux) to break a circulate dependency, as ty_to_str now needs to print out constraints, which may include literals, but pprust depended on ty.
2011-06-01Redo typestate-related data structures to support predicate constraints. No ↵Tim Chevalier-0/+63
actual support yet, just infrastructure.
2011-05-31Now imports are not re-exported unless 'export' is explicitly used.Paul Stansifer-1/+1
2011-05-31Consolidate formatting functions a bit more.Graydon Hoare-98/+10
2011-05-31Fix utility printers to flush eof in common.rs.Graydon Hoare-0/+6
2011-05-31Improve handling of trailing comments.Graydon Hoare-0/+7
2011-05-31Add span to field to catch per-field comments in rec exprs.Graydon Hoare-1/+1
2011-05-31new pretty printerGraydon Hoare-7/+7
2011-05-31rustc: Remove unneeded type params from alt patternsBrian Anderson-1/+1
2011-05-26Remove unused importsTim Chevalier-1/+0
2011-05-26Remove residual uses of fold, and fold itself.Graydon Hoare-26/+18
2011-05-20Make controlflow part of a function typeTim Chevalier-0/+5
Change ty_fn to have a controlflow field. A 'controlflow' is essentially a bit of data that says whether or not this function never returns to the caller (if it never returns, that means it calls "fail" or another "never-returns" function on every control path). Also add syntax for annotating functions that never return: fn foo() -> ! { fail; } for example. Functions marked with ! implicitly have a result type of ty_bot, which is a new type that this commit also adds.
2011-05-19remove now-unused ts field from annTim Chevalier-13/+2
2011-05-19add a bunch more logging thingsTim Chevalier-0/+35
2011-05-17rustc: Don't rebuild the AST when typechecking expressionsPatrick Walton-5/+11
2011-05-17rustc: Flatten annotationsPatrick Walton-11/+0
2011-05-17Finally rename std::_xxx to std::xxxMarijn Haverbeke-9/+9
Except for _task, which is still a keyword.
2011-05-16Started adding support for return checking and non-returning function ↵Tim Chevalier-1/+23
annotations * Reorganized typestate into several modules. * Made typestate check that any function with a non-nil return type returns a value. For now, the check is a warning and not an error (see next item). * Added a "bot" type (prettyprinted as _|_), for constructs like be, ret, break, cont, and fail that don't locally return a value that can be inspected. "bot" is distinct from "nil". There is no concrete syntax for _|_, while the concrete syntax for the nil type is (). * Added support to the parser for a ! annotation on functions whose result type is _|_. Such a function is required to have either a fail or a call to another ! function that is reached in all control flow paths. The point of this annotation is to mark functions like unimpl() and span_err(), so that an alt with a call to err() in one case isn't a false positive for the return-value checker. I haven't actually annotated anything with it yet. * Random bugfixes: * * Fixed bug in trans::trans_binary that was throwing away the cleanups for nested subexpressions of an and or or (tests: box-inside-if and box-inside-if2). ** In typeck, unify the expected type arguments of a tag with the actual specified arguments.
2011-05-13rustc: Write nil types into the node type table wherever plain_ann() is usedPatrick Walton-5/+0
2011-05-12Downcase std modules again, move to :: for module dereferencingMarijn Haverbeke-83/+83
This should be a snapshot transition.
2011-05-12Ensure ann tags are actually kept around during typecheckingMarijn Haverbeke-3/+3
This way, the tag assigned by the parser stays with the node. I realize ann replacing is probably going away real soon, but I needed this now for moving the resolve defs out of the AST.
2011-05-10rustc: Number everything with an annotationPatrick Walton-1/+1
2011-05-09Alias-ify fold and its users, remove another 85kb.Graydon Hoare-3/+3
2011-05-06Rename std modules to be camelcasedMarijn Haverbeke-25/+25
(Have fun mergining your stuff with this.)
2011-05-05Consolidating expr_to_str functions.Lindsey Kuper-4/+4
2011-04-28Fixed bug in typeck that wasn't filling in anns for stmtsTim Chevalier-0/+20
(needed for typestate_check). Also changed a (log; fail) to (log_err; fail) in typestate_check, and added some more logging funs in util.common.
2011-04-28Support all expression forms in typestateTim Chevalier-0/+32
Added support for self_method, cont, chan, port, recv, send, be, do_while, spawn, and ext; handled break and cont correctly. (However, there are no non-xfailed test cases for ext or spawn in stage0 currently.) Although the standard library compiles and all test cases pass with typestate enabled, I left typestate checking disabled as rustc terminates abnormally when building the standard library if so, even though it does generate code correctly.
2011-04-28Further work on typestate_checkTim Chevalier-9/+65
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.
2011-04-25rustc: Pass a "type context" around instead of directly passing the type ↵Patrick Walton-2/+2
store; prep for removing type annotations
2011-04-22rustc: Switch @ty.t to ty.t so that we can change it to a uintPatrick Walton-1/+1
2011-04-21rustc: Pass a type store around, which does nothing yetPatrick Walton-2/+2
2011-04-20rustc: Remove all uses of plain_ty() and friends from outside of ty.rsPatrick Walton-1/+1
2011-04-19Handle nested items correctly in typestate_checkTim Chevalier-0/+29
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-13Make expr_while work in typestate_checkTim Chevalier-2/+2
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-12Further work on typestate. Handles expr_rec and expr_assign now.Tim Chevalier-0/+43
Also changed the ts_ann field on statements to be an ann instead, which explains most of the changes. As well, got rid of the "warning: no type for expression" error by filling in annotations for local decls in typeck (not sure whether this was my fault or not). Finally, in bitv, added a clone() function to copy a bit vector, and fixed is_true, is_false, and to_str to not be nonsense.
2011-04-11rustc: Add a uint hash functionPatrick Walton-0/+8
2011-04-09Move to single-uint file-position representation.Marijn Haverbeke-2/+1
This makes passing them around cheaper. There is now a table (see front/codemap.rs) that is needed to transform such an uint into an actual filename/line/col location. Also cleans up the span building in the parser a bit.
2011-04-08Implemented computing prestates and poststates for a few expression forms.Tim Chevalier-0/+12
The typestate checker (if it's uncommented) now correctly rejects a trivial example program that has an uninitialized variable.
2011-03-31rustc: Mix the bits more when hashing def idsPatrick Walton-9/+8
2011-03-25Another go at changing compile-command, this time using RBUILD env var.Graydon Hoare-1/+1
2011-03-25Revert "Bulk-edit compile commands in emacs chatter to point to assumed ↵Graydon Hoare-1/+1
build/ dir off src root." This reverts commit 846f2e2ba994268725f38c36fa12f1a09f21615c.