diff options
| author | Lindsey Kuper <[email protected]> | 2011-04-07 13:49:27 -0700 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2011-04-07 14:26:34 -0700 |
| commit | 1092bbfff0cf932ef14e5b92cd54133571ca4727 (patch) | |
| tree | a771667972fb8f75d393372032d5f05c03b3b68d /src/comp/middle/fold.rs | |
| parent | Add a very basic crate-dump utility (diff) | |
| download | rust-1092bbfff0cf932ef14e5b92cd54133571ca4727.tar.xz rust-1092bbfff0cf932ef14e5b92cd54133571ca4727.zip | |
Support for self-calls that take arguments.
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).
Diffstat (limited to 'src/comp/middle/fold.rs')
| -rw-r--r-- | src/comp/middle/fold.rs | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/comp/middle/fold.rs b/src/comp/middle/fold.rs index fa85f791..d87c4d08 100644 --- a/src/comp/middle/fold.rs +++ b/src/comp/middle/fold.rs @@ -89,8 +89,7 @@ type ast_fold[ENV] = ann a) -> @expr) fold_expr_call, (fn(&ENV e, &span sp, - ident id, vec[@expr] args, - ann a) -> @expr) fold_expr_call_self, + ident id, ann a) -> @expr) fold_expr_self_method, (fn(&ENV e, &span sp, @expr f, vec[option.t[@expr]] args, @@ -569,9 +568,8 @@ fn fold_expr[ENV](&ENV env, ast_fold[ENV] fld, &@expr e) -> @expr { ret fld.fold_expr_call(env_, e.span, ff, aargs, t); } - case (ast.expr_call_self(?ident, ?args, ?t)) { - auto aargs = fold_exprs(env_, fld, args); - ret fld.fold_expr_call_self(env_, e.span, ident, aargs, t); + case (ast.expr_self_method(?ident, ?t)) { + ret fld.fold_expr_self_method(env_, e.span, ident, t); } case (ast.expr_bind(?f, ?args_opt, ?t)) { @@ -1187,9 +1185,9 @@ fn identity_fold_expr_call[ENV](&ENV env, &span sp, @expr f, ret @respan(sp, ast.expr_call(f, args, a)); } -fn identity_fold_expr_call_self[ENV](&ENV env, &span sp, ident id, - vec[@expr] args, ann a) -> @expr { - ret @respan(sp, ast.expr_call_self(id, args, a)); +fn identity_fold_expr_self_method[ENV](&ENV env, &span sp, ident id, + ann a) -> @expr { + ret @respan(sp, ast.expr_self_method(id, a)); } fn identity_fold_expr_bind[ENV](&ENV env, &span sp, @expr f, @@ -1601,8 +1599,8 @@ fn new_identity_fold[ENV]() -> ast_fold[ENV] { fold_expr_tup = bind identity_fold_expr_tup[ENV](_,_,_,_), fold_expr_rec = bind identity_fold_expr_rec[ENV](_,_,_,_,_), fold_expr_call = bind identity_fold_expr_call[ENV](_,_,_,_,_), - fold_expr_call_self - = bind identity_fold_expr_call_self[ENV](_,_,_,_,_), + fold_expr_self_method + = bind identity_fold_expr_self_method[ENV](_,_,_,_), fold_expr_bind = bind identity_fold_expr_bind[ENV](_,_,_,_,_), fold_expr_spawn = bind identity_fold_expr_spawn[ENV](_,_,_,_,_,_,_), fold_expr_binary = bind identity_fold_expr_binary[ENV](_,_,_,_,_,_), |