about summary refs log tree commit diff
path: root/src/comp/middle/fold.rs
AgeCommit message (Collapse)AuthorLines
2011-05-26Remove residual uses of fold, and fold itself.Graydon Hoare-1868/+0
2011-05-20More work on anonymous objects.Lindsey Kuper-6/+7
2011-05-20Make controlflow part of a function typeTim Chevalier-11/+11
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-17Finally rename std::_xxx to std::xxxMarijn Haverbeke-14/+14
Except for _task, which is still a keyword.
2011-05-16Merge remote branch 'origin/master' into HEADGraydon Hoare-6/+14
Conflicts: src/comp/middle/trans.rs
2011-05-16Rewrite everything to use [] instead of vec() in value position.Graydon Hoare-37/+37
2011-05-16Started adding support for return checking and non-returning function ↵Tim Chevalier-6/+14
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-13More anon obj work; whitespace police in middle::foldLindsey Kuper-31/+39
Passing args to middle::fold::fold_expr_anon_obj by reference to be consistent with the other folds; adding a dummy fold_expr_anon_obj to typeck to be filled in later.
2011-05-13Use new module namespace syntax.Lindsey Kuper-30/+30
2011-05-13More progress on anonymous objects.Lindsey Kuper-1/+74
Still segfaulting on the method-overriding.rs test, though.
2011-05-12Downcase std modules again, move to :: for module dereferencingMarijn Haverbeke-374/+375
This should be a snapshot transition.
2011-05-12Keep resolve data in external hash table, rather than embedded defsMarijn Haverbeke-18/+15
One step closer to removing fold and having a single, immutable AST. Resolve still uses fold, because it has to detect and transform expr_field expressions. If we go through on our plan of moving to a different syntax for module dereferencing, the parser can spit out expr_field expressions, and resolve can move to walk. (I am truly sorry for the things I did in typestate_check.rs. I expect we'll want to change that to walk as well in the near future, at which point it should probably pass around a context record, which could hold the def_map.)
2011-05-11Remove mod indices from the ASTMarijn Haverbeke-8/+2
They are now created by the resolve pass, which is the only pass that needs them, and kept internal to that pass.
2011-05-11Get rid of arm indicesMarijn Haverbeke-1/+1
2011-05-11Get rid of block indicesMarijn Haverbeke-3/+1
2011-05-11Rewrite comp/middle/resolve.rsMarijn Haverbeke-9/+6
* Cleans up the algorithm * Move first pass to walk (second still folds) * Support part of a type/value namespace split (crate metadata and module indices still need to be taught about this) * Remove a few blatant inefficiencies (import tables being recreated for every lookup, most importantly)
2011-05-09Fix long lines in fold.rs, typeck.rsBrian Anderson-1/+2
2011-05-09Alias-ify fold and its users, remove another 85kb.Graydon Hoare-279/+297
2011-05-06Rename std modules to be camelcasedMarijn Haverbeke-49/+49
(Have fun mergining your stuff with this.)
2011-05-05Bring back "pred" syntax for writing predicates for checkTim Chevalier-5/+8
This commit reinstates the requirement that the predicate in a "check" must be a manifest call to a special kind of function declared with the new "pred" keyword instead of "fn". Preds must have a boolean return type and can only call other preds; they can't have any effects (as enforced by the typechecker). The arguments to a predicate in a check expression must be slot variables or literals.
2011-05-05Check that the operand in a check is a callTim Chevalier-1/+1
In addition, fix bug in fold that was turning asserts into checks. More typechecking still needs to be done.
2011-05-02Un-revert "Use different syntax for checks that matter to typestate", fixing ↵Patrick Walton-7/+24
the problem. This reverts commit d08b443fffb1181d8d45ae5d061412f202dd4118.
2011-05-02Revert "Use different syntax for checks that matter to typestate"Graydon Hoare-24/+7
This reverts commit aa25f22f197682de3b18fc4c8ba068d1feda220f. It broke stage2, not sure why yet.
2011-05-02Use different syntax for checks that matter to typestateTim Chevalier-7/+24
This giant commit changes the syntax of Rust to use "assert" for "check" expressions that didn't mean anything to the typestate system, and continue using "check" for checks that are used as part of typestate checking. Most of the changes are just replacing "check" with "assert" in test cases and rustc.
2011-04-21Fix the signature of expr_extBrian Anderson-2/+2
The extension body is just a string, not an expression.
2011-04-19Handle nested items correctly in typestate_checkTim Chevalier-3/+0
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-19Remove effect system from src.Graydon Hoare-17/+15
2011-04-19add log_err to rustcMarijn Haverbeke-6/+6
2011-04-14Work on destructors, not entirely functional yet (no tydesc integration).Graydon Hoare-6/+6
2011-04-12typestate_check can now handle expr_block, expr_if, and expr_binaryTim Chevalier-1/+2
(caveat for the latter: it assumes that binary operations are strict; a TODO is to detect or and and and correctly reflect that they're lazy in the second argument). I had to add an ann field to ast.block, resulting in the usual boilerplate changes. Test cases that currently work (if you uncomment the typestate pass in the driver) (all these are under test/compile-fail): fru-typestate ret-uninit use-uninit use-uninit-2 use-uninit-3
2011-04-12Further work on typestate. Handles expr_rec and expr_assign now.Tim Chevalier-10/+12
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-08rustc: Add the ability to fold over annotationsPatrick Walton-36/+83
2011-04-07Support for self-calls that take arguments.Lindsey Kuper-10/+8
Nicer parsing of self-calls (expr_self_method nodes inside expr_call nodes, rather than a separate expr_call_self) makes typechecking tractable. We can now write self-calls that take arguments and return values (see: test/run-pass/obj-self-*.rs).
2011-04-06Continued sketching out code for checking states against preconditions.Tim Chevalier-12/+17
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-05Further on the path toward self-awareness.Lindsey Kuper-6/+5
Mostly: * Merciless refactoring of trans.rs so that trans_call can work for self-calls as well as other kinds of calls Also: * Various changes to go with having idents, rather than exprs, in expr_call_self AST nodes * Added missing case for SELF token to token.to_str()
2011-04-01Started adding support for typestate checking.Tim Chevalier-48/+50
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-03-31rustc: Add a type annotation to tag itemsPatrick Walton-6/+6
2011-03-31More machinery for adding an expr_call_self AST node.Lindsey Kuper-1/+18
2011-03-31Improve line comment positioningMarijn Haverbeke-3/+4
This involved making ast.variant spanned.
2011-03-31Add effect field to ast.ty_fn.Marijn Haverbeke-11/+12
Still not used, except by the pretty-printer.
2011-03-30rustc: Thread an item-to-type mapping throughout the typechecking and ↵Patrick Walton-5/+5
translation phases
2011-03-28Add expr_spawn, spawn parsing, folding, typechecking, ty_taskBrian Anderson-0/+18
2011-03-27Add support for break and cont to rustcMarijn Haverbeke-0/+22
Testing proper cleanup is hampered by https://github.com/graydon/rust/issues/293
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.
2011-03-25Bulk-edit compile commands in emacs chatter to point to assumed build/ dir ↵Graydon Hoare-1/+1
off src root.
2011-03-25rustc: Store cached crate metadata in the sessionPatrick Walton-5/+6
2011-03-25Implement local declarations with receive. Un-XFAIL decl-with-recv.rs.Brian Anderson-5/+4
2011-03-25Refactor ast.local to make room for initialization via recvBrian Anderson-4/+6
2011-03-23Support for 'float' in type signatures.Lindsey Kuper-1/+8