about summary refs log tree commit diff
path: root/src/comp
diff options
context:
space:
mode:
authorLindsey Kuper <lkuper@mozilla.com>2011-03-30 16:27:37 -0700
committerGraydon Hoare <graydon@mozilla.com>2011-03-31 14:04:53 -0700
commite939d6f17c8dce7c2154c08ee044b749cbba41f4 (patch)
tree4c636b2d5ff843370402552c616e8dbc51d2c442 /src/comp
parenta505e3c0ecf447893dd698a2e87d88694c86e0fa (diff)
downloadrust-e939d6f17c8dce7c2154c08ee044b749cbba41f4.tar.gz
rust-e939d6f17c8dce7c2154c08ee044b749cbba41f4.zip
More machinery for adding an expr_call_self AST node.
Diffstat (limited to 'src/comp')
-rw-r--r--src/comp/middle/fold.rs19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/comp/middle/fold.rs b/src/comp/middle/fold.rs
index 0b1a01ad6b4..0c25052c8e9 100644
--- a/src/comp/middle/fold.rs
+++ b/src/comp/middle/fold.rs
@@ -1,5 +1,5 @@
 import std.map.hashmap;
- import std.option;
+import std.option;
 import std.option.some;
 import std.option.none;
 
@@ -88,6 +88,10 @@ type ast_fold[ENV] =
          ann a) -> @expr)                         fold_expr_call,
 
      (fn(&ENV e, &span sp,
+         @expr f, vec[@expr] args,
+         ann a) -> @expr)                         fold_expr_call_self,
+
+     (fn(&ENV e, &span sp,
          @expr f, vec[option.t[@expr]] args,
          ann a) -> @expr)                         fold_expr_bind,
 
@@ -562,6 +566,12 @@ 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(?f, ?args, ?t)) {
+            auto ff = fold_expr(env_, fld, f);
+            auto aargs = fold_exprs(env_, fld, args);
+            ret fld.fold_expr_call_self(env_, e.span, ff, aargs, t);
+        }
+
         case (ast.expr_bind(?f, ?args_opt, ?t)) {
             auto ff = fold_expr(env_, fld, f);
             let vec[option.t[@ast.expr]] aargs_opt = vec();
@@ -1175,6 +1185,11 @@ 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, @expr f,
+                                vec[@expr] args, ann a) -> @expr {
+    ret @respan(sp, ast.expr_call_self(f, args, a));
+}
+
 fn identity_fold_expr_bind[ENV](&ENV env, &span sp, @expr f,
                                 vec[option.t[@expr]] args_opt, ann a)
         -> @expr {
@@ -1580,6 +1595,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_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](_,_,_,_,_,_),