diff options
| author | Tim Chevalier <chevalier@alum.wellesley.edu> | 2011-04-12 12:16:21 -0700 |
|---|---|---|
| committer | Graydon Hoare <graydon@mozilla.com> | 2011-04-12 14:31:46 -0700 |
| commit | d7e881841438cfe0797b71ff35ea96c8f2477a76 (patch) | |
| tree | 727e73ccf9138df34a1ad3585ef00559e526b2c6 /src/comp/front | |
| parent | 87d17c3a2cfbdaf3d860a9df171c6be220aaab5e (diff) | |
| download | rust-d7e881841438cfe0797b71ff35ea96c8f2477a76.tar.gz 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/front')
| -rw-r--r-- | src/comp/front/ast.rs | 6 | ||||
| -rw-r--r-- | src/comp/front/parser.rs | 16 |
2 files changed, 13 insertions, 9 deletions
diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index 4f7a2538270..50517f003c3 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -215,8 +215,10 @@ tag mode { type stmt = spanned[stmt_]; tag stmt_ { - stmt_decl(@decl, option.t[@ts_ann]); - stmt_expr(@expr, option.t[@ts_ann]); +/* Only the ts_ann field is meaningful for statements, + but we make it an ann to make traversals simpler */ + stmt_decl(@decl, ann); + stmt_expr(@expr, ann); // These only exist in crate-level blocks. stmt_crate_directive(@crate_directive); } diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs index 617f18135b1..9410465579c 100644 --- a/src/comp/front/parser.rs +++ b/src/comp/front/parser.rs @@ -11,7 +11,7 @@ import util.common; import util.common.filename; import util.common.span; import util.common.new_str_hash; -import util.typestate_ann.ts_ann; +import util.common.plain_ann; tag restriction { UNRESTRICTED; @@ -1562,14 +1562,15 @@ impure fn parse_source_stmt(parser p) -> @ast.stmt { case (token.LET) { auto decl = parse_let(p); - ret @spanned(lo, decl.span.hi, - ast.stmt_decl(decl, none[@ts_ann])); + auto hi = p.get_span(); + ret @spanned + (lo, decl.span.hi, ast.stmt_decl(decl, plain_ann())); } case (token.AUTO) { auto decl = parse_auto(p); - ret @spanned(lo, decl.span.hi, - ast.stmt_decl(decl, none[@ts_ann])); + auto hi = p.get_span(); + ret @spanned(lo, decl.span.hi, ast.stmt_decl(decl, plain_ann())); } case (_) { @@ -1578,12 +1579,13 @@ impure fn parse_source_stmt(parser p) -> @ast.stmt { auto i = parse_item(p); auto hi = i.span.hi; auto decl = @spanned(lo, hi, ast.decl_item(i)); - ret @spanned(lo, hi, ast.stmt_decl(decl, none[@ts_ann])); + ret @spanned(lo, hi, ast.stmt_decl(decl, plain_ann())); } else { // Remainder are line-expr stmts. auto e = parse_expr(p); - ret @spanned(lo, e.span.hi, ast.stmt_expr(e, none[@ts_ann])); + auto hi = p.get_span(); + ret @spanned(lo, e.span.hi, ast.stmt_expr(e, plain_ann())); } } } |
