diff options
| author | Tim Chevalier <[email protected]> | 2011-04-12 12:16:21 -0700 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2011-04-12 14:31:46 -0700 |
| commit | d7e881841438cfe0797b71ff35ea96c8f2477a76 (patch) | |
| tree | 727e73ccf9138df34a1ad3585ef00559e526b2c6 /src/comp/middle/fold.rs | |
| parent | Add LLVMAddLoopIdiomPass. (diff) | |
| download | rust-d7e881841438cfe0797b71ff35ea96c8f2477a76.tar.xz rust-d7e881841438cfe0797b71ff35ea96c8f2477a76.zip | |
Further work on typestate. Handles expr_rec and expr_assign now.
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.
Diffstat (limited to 'src/comp/middle/fold.rs')
| -rw-r--r-- | src/comp/middle/fold.rs | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/comp/middle/fold.rs b/src/comp/middle/fold.rs index 048e69be..e9c4ee2a 100644 --- a/src/comp/middle/fold.rs +++ b/src/comp/middle/fold.rs @@ -232,11 +232,11 @@ type ast_fold[ENV] = // Stmt folds. (fn(&ENV e, &span sp, - @decl decl, option.t[@ts_ann] a) + @decl decl, ann a) -> @stmt) fold_stmt_decl, (fn(&ENV e, &span sp, - @expr e, option.t[@ts_ann] a) + @expr e, ann a) -> @stmt) fold_stmt_expr, // Item folds. @@ -470,7 +470,9 @@ fn fold_decl[ENV](&ENV env, ast_fold[ENV] fld, @decl d) -> @decl { } case (_) { /* fall through */ } } - let @ast.local local_ = @rec(ty=ty_, init=init_ with *local); + auto ann_ = fld.fold_ann(env_, local.ann); + let @ast.local local_ = + @rec(ty=ty_, init=init_, ann=ann_ with *local); ret fld.fold_decl_local(env_, d.span, local_); } @@ -830,12 +832,14 @@ fn fold_stmt[ENV](&ENV env, ast_fold[ENV] fld, &@stmt s) -> @stmt { alt (s.node) { case (ast.stmt_decl(?d, ?a)) { auto dd = fold_decl(env_, fld, d); - ret fld.fold_stmt_decl(env_, s.span, dd, a); + auto aa = fld.fold_ann(env_, a); + ret fld.fold_stmt_decl(env_, s.span, dd, aa); } case (ast.stmt_expr(?e, ?a)) { auto ee = fold_expr(env_, fld, e); - ret fld.fold_stmt_expr(env_, s.span, ee, a); + auto aa = fld.fold_ann(env_, a); + ret fld.fold_stmt_expr(env_, s.span, ee, aa); } } fail; @@ -1426,13 +1430,11 @@ fn identity_fold_pat_tag[ENV](&ENV e, &span sp, path p, vec[@pat] args, // Stmt identities. -fn identity_fold_stmt_decl[ENV](&ENV env, &span sp, @decl d, - option.t[@ts_ann] a) -> @stmt { +fn identity_fold_stmt_decl[ENV](&ENV env, &span sp, @decl d, ann a) -> @stmt { ret @respan(sp, ast.stmt_decl(d, a)); } -fn identity_fold_stmt_expr[ENV](&ENV e, &span sp, @expr x, - option.t[@ts_ann] a) -> @stmt { +fn identity_fold_stmt_expr[ENV](&ENV e, &span sp, @expr x, ann a) -> @stmt { ret @respan(sp, ast.stmt_expr(x, a)); } @@ -1705,7 +1707,7 @@ fn new_identity_fold[ENV]() -> ast_fold[ENV] { bind identity_fold_native_item_ty[ENV](_,_,_,_), fold_item_tag = bind identity_fold_item_tag[ENV](_,_,_,_,_,_,_), fold_item_obj = bind identity_fold_item_obj[ENV](_,_,_,_,_,_,_), - + fold_view_item_use = bind identity_fold_view_item_use[ENV](_,_,_,_,_,_), fold_view_item_import = |