aboutsummaryrefslogtreecommitdiff
path: root/src/comp
diff options
context:
space:
mode:
authorGraydon Hoare <[email protected]>2010-12-30 17:46:35 -0800
committerGraydon Hoare <[email protected]>2010-12-30 17:46:35 -0800
commita99713265baca22050e1ab4994feaa70ac31667b (patch)
treec6796d1974b96566e52b80767ce6e5340f565068 /src/comp
parentUn-XFAIL stateful-obj.rs for rustc. (diff)
downloadrust-a99713265baca22050e1ab4994feaa70ac31667b.tar.xz
rust-a99713265baca22050e1ab4994feaa70ac31667b.zip
Teach fold about ty_obj.
Diffstat (limited to 'src/comp')
-rw-r--r--src/comp/middle/fold.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/comp/middle/fold.rs b/src/comp/middle/fold.rs
index d8efa25d..54570709 100644
--- a/src/comp/middle/fold.rs
+++ b/src/comp/middle/fold.rs
@@ -52,6 +52,9 @@ type ast_fold[ENV] =
vec[ast.ty_field] elts) -> @ty) fold_ty_rec,
(fn(&ENV e, &span sp,
+ vec[ast.ty_method] meths) -> @ty) fold_ty_obj,
+
+ (fn(&ENV e, &span sp,
vec[rec(ast.mode mode, @ty ty)] inputs,
@ty output) -> @ty) fold_ty_fn,
@@ -291,6 +294,21 @@ fn fold_ty[ENV](&ENV env, ast_fold[ENV] fld, @ty t) -> @ty {
ret fld.fold_ty_rec(env_, t.span, flds_);
}
+ case (ast.ty_obj(?meths)) {
+ let vec[ast.ty_method] meths_ = vec();
+ for (ast.ty_method m in meths) {
+ auto tfn = fld.fold_ty_fn(env_, t.span,
+ m.inputs, m.output);
+ alt (tfn.node) {
+ case (ast.ty_fn(?ins, ?out)) {
+ append[ast.ty_method]
+ (meths_, rec(inputs=ins, output=out with m));
+ }
+ }
+ }
+ ret fld.fold_ty_obj(env_, t.span, meths_);
+ }
+
case (ast.ty_path(?pth, ?ref_opt)) {
let vec[ast.name] path = vec();
for (ast.name n in pth) {
@@ -787,6 +805,11 @@ fn identity_fold_ty_rec[ENV](&ENV env, &span sp,
ret @respan(sp, ast.ty_rec(elts));
}
+fn identity_fold_ty_obj[ENV](&ENV env, &span sp,
+ vec[ast.ty_method] meths) -> @ty {
+ ret @respan(sp, ast.ty_obj(meths));
+}
+
fn identity_fold_ty_fn[ENV](&ENV env, &span sp,
vec[rec(ast.mode mode, @ty ty)] inputs,
@ty output) -> @ty {
@@ -1091,6 +1114,7 @@ fn new_identity_fold[ENV]() -> ast_fold[ENV] {
fold_ty_vec = bind identity_fold_ty_vec[ENV](_,_,_),
fold_ty_tup = bind identity_fold_ty_tup[ENV](_,_,_),
fold_ty_rec = bind identity_fold_ty_rec[ENV](_,_,_),
+ fold_ty_obj = bind identity_fold_ty_obj[ENV](_,_,_),
fold_ty_fn = bind identity_fold_ty_fn[ENV](_,_,_,_),
fold_ty_path = bind identity_fold_ty_path[ENV](_,_,_,_),
fold_ty_mutable = bind identity_fold_ty_mutable[ENV](_,_,_),