Skip to content

Commit e939d6f

Browse files
lkupergraydon
authored andcommitted
More machinery for adding an expr_call_self AST node.
1 parent a505e3c commit e939d6f

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/comp/middle/fold.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import std.map.hashmap;
2-
import std.option;
2+
import std.option;
33
import std.option.some;
44
import std.option.none;
55

@@ -87,6 +87,10 @@ type ast_fold[ENV] =
8787
@expr f, vec[@expr] args,
8888
ann a) -> @expr) fold_expr_call,
8989

90+
(fn(&ENV e, &span sp,
91+
@expr f, vec[@expr] args,
92+
ann a) -> @expr) fold_expr_call_self,
93+
9094
(fn(&ENV e, &span sp,
9195
@expr f, vec[option.t[@expr]] args,
9296
ann a) -> @expr) fold_expr_bind,
@@ -562,6 +566,12 @@ fn fold_expr[ENV](&ENV env, ast_fold[ENV] fld, &@expr e) -> @expr {
562566
ret fld.fold_expr_call(env_, e.span, ff, aargs, t);
563567
}
564568

569+
case (ast.expr_call_self(?f, ?args, ?t)) {
570+
auto ff = fold_expr(env_, fld, f);
571+
auto aargs = fold_exprs(env_, fld, args);
572+
ret fld.fold_expr_call_self(env_, e.span, ff, aargs, t);
573+
}
574+
565575
case (ast.expr_bind(?f, ?args_opt, ?t)) {
566576
auto ff = fold_expr(env_, fld, f);
567577
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,
11751185
ret @respan(sp, ast.expr_call(f, args, a));
11761186
}
11771187

1188+
fn identity_fold_expr_call_self[ENV](&ENV env, &span sp, @expr f,
1189+
vec[@expr] args, ann a) -> @expr {
1190+
ret @respan(sp, ast.expr_call_self(f, args, a));
1191+
}
1192+
11781193
fn identity_fold_expr_bind[ENV](&ENV env, &span sp, @expr f,
11791194
vec[option.t[@expr]] args_opt, ann a)
11801195
-> @expr {
@@ -1580,6 +1595,8 @@ fn new_identity_fold[ENV]() -> ast_fold[ENV] {
15801595
fold_expr_tup = bind identity_fold_expr_tup[ENV](_,_,_,_),
15811596
fold_expr_rec = bind identity_fold_expr_rec[ENV](_,_,_,_,_),
15821597
fold_expr_call = bind identity_fold_expr_call[ENV](_,_,_,_,_),
1598+
fold_expr_call_self
1599+
= bind identity_fold_expr_call_self[ENV](_,_,_,_,_),
15831600
fold_expr_bind = bind identity_fold_expr_bind[ENV](_,_,_,_,_),
15841601
fold_expr_spawn = bind identity_fold_expr_spawn[ENV](_,_,_,_,_,_,_),
15851602
fold_expr_binary = bind identity_fold_expr_binary[ENV](_,_,_,_,_,_),

0 commit comments

Comments
 (0)