Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fold function output type and argument types #204

Merged
1 commit merged into from
Jan 19, 2011
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/comp/middle/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,7 @@ fn fold_ty[ENV](&ENV env, ast_fold[ENV] fld, @ty t) -> @ty {
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);
auto tfn = fold_ty_fn(env_, fld, t.span, m.inputs, m.output);
alt (tfn.node) {
case (ast.ty_fn(?ins, ?out)) {
append[ast.ty_method]
Expand All @@ -330,11 +329,24 @@ fn fold_ty[ENV](&ENV env, ast_fold[ENV] fld, @ty t) -> @ty {
}

case (ast.ty_fn(?inputs, ?output)) {
ret fld.fold_ty_fn(env_, t.span, inputs, output);
ret fold_ty_fn(env_, fld, t.span, inputs, output);
}
}
}

fn fold_ty_fn[ENV](&ENV env, ast_fold[ENV] fld, &span sp,
vec[rec(ast.mode mode, @ty ty)] inputs,
@ty output) -> @ty {
auto output_ = fold_ty(env, fld, output);
let vec[rec(ast.mode mode, @ty ty)] inputs_ = vec();
for (rec(ast.mode mode, @ty ty) input in inputs) {
auto ty_ = fold_ty(env, fld, input.ty);
auto input_ = rec(ty=ty_ with input);
inputs_ += vec(input_);
}
ret fld.fold_ty_fn(env, sp, inputs_, output_);
}

fn fold_decl[ENV](&ENV env, ast_fold[ENV] fld, @decl d) -> @decl {
let ENV env_ = fld.update_env_for_decl(env, d);

Expand Down