diff options
| author | Patrick Walton <[email protected]> | 2010-11-10 18:19:27 -0800 |
|---|---|---|
| committer | Patrick Walton <[email protected]> | 2010-11-10 18:20:02 -0800 |
| commit | c3bc88a3251bc966eb128edbf4803e0a88cc06ff (patch) | |
| tree | 174f0f7120b059ddec4de355e2e179a8c4aab152 /src/comp/middle | |
| parent | Redo the scheme for block context chaining and termination, to simplify and s... (diff) | |
| download | rust-c3bc88a3251bc966eb128edbf4803e0a88cc06ff.tar.xz rust-c3bc88a3251bc966eb128edbf4803e0a88cc06ff.zip | |
rustc: Add an annotation to function and type items so that the typechecker can store types with them
Diffstat (limited to 'src/comp/middle')
| -rw-r--r-- | src/comp/middle/fold.rs | 24 | ||||
| -rw-r--r-- | src/comp/middle/resolve.rs | 6 | ||||
| -rw-r--r-- | src/comp/middle/trans.rs | 6 |
3 files changed, 18 insertions, 18 deletions
diff --git a/src/comp/middle/fold.rs b/src/comp/middle/fold.rs index 51b9595a..6ad65544 100644 --- a/src/comp/middle/fold.rs +++ b/src/comp/middle/fold.rs @@ -140,13 +140,13 @@ type ast_fold[ENV] = // Item folds. (fn(&ENV e, &span sp, ident ident, - &ast._fn f, def_id id) -> @item) fold_item_fn, + &ast._fn f, def_id id, ann a) -> @item) fold_item_fn, (fn(&ENV e, &span sp, ident ident, &ast._mod m, def_id id) -> @item) fold_item_mod, (fn(&ENV e, &span sp, ident ident, - @ty t, def_id id) -> @item) fold_item_ty, + @ty t, def_id id, ann a) -> @item) fold_item_ty, // Additional nodes. (fn(&ENV e, &span sp, @@ -481,9 +481,9 @@ fn fold_item[ENV](&ENV env, ast_fold[ENV] fld, @item i) -> @item { alt (i.node) { - case (ast.item_fn(?ident, ?ff, ?id)) { + case (ast.item_fn(?ident, ?ff, ?id, ?ann)) { let ast._fn ff_ = fold_fn[ENV](env_, fld, ff); - ret fld.fold_item_fn(env_, i.span, ident, ff_, id); + ret fld.fold_item_fn(env_, i.span, ident, ff_, id, ann); } case (ast.item_mod(?ident, ?mm, ?id)) { @@ -491,9 +491,9 @@ fn fold_item[ENV](&ENV env, ast_fold[ENV] fld, @item i) -> @item { ret fld.fold_item_mod(env_, i.span, ident, mm_, id); } - case (ast.item_ty(?ident, ?ty, ?id)) { + case (ast.item_ty(?ident, ?ty, ?id, ?ann)) { let @ast.ty ty_ = fold_ty[ENV](env_, fld, ty); - ret fld.fold_item_ty(env_, i.span, ident, ty_, id); + ret fld.fold_item_ty(env_, i.span, ident, ty_, id, ann); } } @@ -709,8 +709,8 @@ fn identity_fold_stmt_expr[ENV](&ENV e, &span sp, @expr x) -> @stmt { // Item identities. fn identity_fold_item_fn[ENV](&ENV e, &span sp, ident i, - &ast._fn f, def_id id) -> @item { - ret @respan(sp, ast.item_fn(i, f, id)); + &ast._fn f, def_id id, ann a) -> @item { + ret @respan(sp, ast.item_fn(i, f, id, a)); } fn identity_fold_item_mod[ENV](&ENV e, &span sp, ident i, @@ -719,8 +719,8 @@ fn identity_fold_item_mod[ENV](&ENV e, &span sp, ident i, } fn identity_fold_item_ty[ENV](&ENV e, &span sp, ident i, - @ty t, def_id id) -> @item { - ret @respan(sp, ast.item_ty(i, t, id)); + @ty t, def_id id, ann a) -> @item { + ret @respan(sp, ast.item_ty(i, t, id, a)); } @@ -829,9 +829,9 @@ fn new_identity_fold[ENV]() -> ast_fold[ENV] { = bind identity_fold_stmt_check_expr[ENV](_,_,_), fold_stmt_expr = bind identity_fold_stmt_expr[ENV](_,_,_), - fold_item_fn = bind identity_fold_item_fn[ENV](_,_,_,_,_), + fold_item_fn = bind identity_fold_item_fn[ENV](_,_,_,_,_,_), fold_item_mod = bind identity_fold_item_mod[ENV](_,_,_,_,_), - fold_item_ty = bind identity_fold_item_ty[ENV](_,_,_,_,_), + fold_item_ty = bind identity_fold_item_ty[ENV](_,_,_,_,_,_), fold_block = bind identity_fold_block[ENV](_,_,_), fold_fn = bind identity_fold_fn[ENV](_,_,_,_), diff --git a/src/comp/middle/resolve.rs b/src/comp/middle/resolve.rs index 875996db..9e999bdd 100644 --- a/src/comp/middle/resolve.rs +++ b/src/comp/middle/resolve.rs @@ -28,13 +28,13 @@ fn lookup_name(&env e, ast.ident i) -> option.t[def] { fn found_def_item(@ast.item i) -> option.t[def] { alt (i.node) { - case (ast.item_fn(_, _, ?id)) { + case (ast.item_fn(_, _, ?id, _)) { ret some[def](ast.def_fn(id)); } case (ast.item_mod(_, _, ?id)) { ret some[def](ast.def_mod(id)); } - case (ast.item_ty(_, _, ?id)) { + case (ast.item_ty(_, _, ?id, _)) { ret some[def](ast.def_ty(id)); } } @@ -75,7 +75,7 @@ fn lookup_name(&env e, ast.ident i) -> option.t[def] { case (scope_item(?it)) { alt (it.node) { - case (ast.item_fn(_, ?f, _)) { + case (ast.item_fn(_, ?f, _, _)) { for (ast.arg a in f.inputs) { if (_str.eq(a.ident, i)) { ret some[def](ast.def_arg(a.id)); diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index d2afa467..bd1836b5 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -914,7 +914,7 @@ impure fn trans_expr(@block_ctxt cx, &ast.expr e) -> result { // perhaps to pick a more tasteful one. auto outptr = cx.fcx.lloutptr; alt (cx.fcx.tcx.items.get(f_res._2).node) { - case (ast.item_fn(_, ?ff, _)) { + case (ast.item_fn(_, ?ff, _, _)) { outptr = cx.build.Alloca(type_of(cx.fcx.tcx, ff.output)); } } @@ -1182,7 +1182,7 @@ impure fn trans_fn(@trans_ctxt cx, &ast._fn f, ast.def_id fid) { impure fn trans_item(@trans_ctxt cx, &ast.item item) { alt (item.node) { - case (ast.item_fn(?name, ?f, ?fid)) { + case (ast.item_fn(?name, ?f, ?fid, _)) { auto sub_cx = @rec(path=cx.path + "." + name with *cx); trans_fn(sub_cx, f, fid); } @@ -1202,7 +1202,7 @@ impure fn trans_mod(@trans_ctxt cx, &ast._mod m) { fn collect_item(&@trans_ctxt cx, @ast.item i) -> @trans_ctxt { alt (i.node) { - case (ast.item_fn(?name, ?f, ?fid)) { + case (ast.item_fn(?name, ?f, ?fid, _)) { cx.items.insert(fid, i); let vec[TypeRef] args = vec(T_ptr(type_of(cx, f.output)), // outptr. |