Add support to pat_lit to fold.

This commit is contained in:
Graydon Hoare 2011-02-10 19:13:47 -08:00
parent 277334890d
commit f951b52e91

View File

@ -160,6 +160,9 @@ type ast_fold[ENV] =
(fn(&ENV e, &span sp,
ann a) -> @pat) fold_pat_wild,
(fn(&ENV e, &span sp,
@ast.lit lit, ann a) -> @pat) fold_pat_lit,
(fn(&ENV e, &span sp,
ident i, def_id did, ann a) -> @pat) fold_pat_bind,
@ -421,6 +424,9 @@ fn fold_pat[ENV](&ENV env, ast_fold[ENV] fld, @ast.pat p) -> @ast.pat {
alt (p.node) {
case (ast.pat_wild(?t)) { ret fld.fold_pat_wild(env_, p.span, t); }
case (ast.pat_lit(?lt, ?t)) {
ret fld.fold_pat_lit(env_, p.span, lt, t);
}
case (ast.pat_bind(?id, ?did, ?t)) {
ret fld.fold_pat_bind(env_, p.span, id, did, t);
}
@ -1122,6 +1128,10 @@ fn identity_fold_pat_wild[ENV](&ENV e, &span sp, ann a) -> @pat {
ret @respan(sp, ast.pat_wild(a));
}
fn identity_fold_pat_lit[ENV](&ENV e, &span sp, @ast.lit lit, ann a) -> @pat {
ret @respan(sp, ast.pat_lit(lit, a));
}
fn identity_fold_pat_bind[ENV](&ENV e, &span sp, ident i, def_id did, ann a)
-> @pat {
ret @respan(sp, ast.pat_bind(i, did, a));
@ -1373,6 +1383,7 @@ fn new_identity_fold[ENV]() -> ast_fold[ENV] {
fold_decl_item = bind identity_fold_decl_item[ENV](_,_,_),
fold_pat_wild = bind identity_fold_pat_wild[ENV](_,_,_),
fold_pat_lit = bind identity_fold_pat_lit[ENV](_,_,_,_),
fold_pat_bind = bind identity_fold_pat_bind[ENV](_,_,_,_,_),
fold_pat_tag = bind identity_fold_pat_tag[ENV](_,_,_,_,_,_),