Get rid of arm indices

This commit is contained in:
Marijn Haverbeke
2011-05-11 15:26:36 +02:00
parent 5405f45274
commit fe29d24b6e
6 changed files with 26 additions and 36 deletions

View File

@@ -1367,9 +1367,8 @@ fn parse_alt_expr(parser p) -> @ast.expr {
expect(p, token.LPAREN);
auto pat = parse_pat(p);
expect(p, token.RPAREN);
auto index = index_arm(pat);
auto block = parse_block(p);
arms += vec(rec(pat=pat, block=block, index=index));
arms += vec(rec(pat=pat, block=block));
}
// FIXME: this is a vestigial form left over from
@@ -1384,9 +1383,8 @@ fn parse_alt_expr(parser p) -> @ast.expr {
p.bump();
auto hi = p.get_hi_pos();
auto pat = @spanned(lo, hi, ast.pat_wild(p.get_ann()));
auto index = index_arm(pat);
auto block = parse_block(p);
arms += vec(rec(pat=pat, block=block, index=index));
arms += vec(rec(pat=pat, block=block));
}
case (token.RBRACE) { /* empty */ }
case (?tok) {
@@ -1626,25 +1624,6 @@ fn parse_source_stmt(parser p) -> @ast.stmt {
fail;
}
fn index_arm(@ast.pat pat) -> hashmap[ast.ident,ast.def_id] {
fn do_index_arm(&hashmap[ast.ident,ast.def_id] index, @ast.pat pat) {
alt (pat.node) {
case (ast.pat_bind(?i, ?def_id, _)) { index.insert(i, def_id); }
case (ast.pat_wild(_)) { /* empty */ }
case (ast.pat_lit(_, _)) { /* empty */ }
case (ast.pat_tag(_, ?pats, _, _)) {
for (@ast.pat p in pats) {
do_index_arm(index, p);
}
}
}
}
auto index = new_str_hash[ast.def_id]();
do_index_arm(index, pat);
ret index;
}
fn stmt_to_expr(@ast.stmt stmt) -> Option.t[@ast.expr] {
alt (stmt.node) {
case (ast.stmt_expr(?e,_)) { ret some[@ast.expr](e); }