aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRafael Ávila de Espíndola <[email protected]>2011-02-25 12:08:21 -0500
committerRafael Ávila de Espíndola <[email protected]>2011-02-25 12:08:21 -0500
commitf8f6f078c505dd0f20526e3ad86c360605fce109 (patch)
treed333e5b301e72337ac23e290ae98717b0ece568e /src
parentDisable test that is failing on valgrind. (diff)
downloadrust-f8f6f078c505dd0f20526e3ad86c360605fce109.tar.xz
rust-f8f6f078c505dd0f20526e3ad86c360605fce109.zip
There are no native iterators (or at least they are not going to be supported
soon.).
Diffstat (limited to 'src')
-rw-r--r--src/comp/front/ast.rs2
-rw-r--r--src/comp/front/parser.rs31
-rw-r--r--src/comp/middle/fold.rs17
-rw-r--r--src/comp/middle/trans.rs2
-rw-r--r--src/comp/middle/typeck.rs19
5 files changed, 38 insertions, 33 deletions
diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs
index f5c03bd7..9b995f9a 100644
--- a/src/comp/front/ast.rs
+++ b/src/comp/front/ast.rs
@@ -235,10 +235,10 @@ tag ty_ {
type arg = rec(mode mode, @ty ty, ident ident, def_id id);
type fn_decl = rec(effect effect,
- proto proto,
vec[arg] inputs,
@ty output);
type _fn = rec(fn_decl decl,
+ proto proto,
block body);
diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs
index 67b9cc80..7bd34fdf 100644
--- a/src/comp/front/parser.rs
+++ b/src/comp/front/parser.rs
@@ -1617,8 +1617,7 @@ impure fn parse_ty_params(parser p) -> vec[ast.ty_param] {
ret ty_params;
}
-impure fn parse_fn_decl(parser p, ast.proto proto,
- ast.effect eff) -> ast.fn_decl {
+impure fn parse_fn_decl(parser p, ast.effect eff) -> ast.fn_decl {
auto pf = parse_arg;
let util.common.spanned[vec[ast.arg]] inputs =
// FIXME: passing parse_arg as an lval doesn't work at the
@@ -1636,32 +1635,32 @@ impure fn parse_fn_decl(parser p, ast.proto proto,
} else {
output = @spanned(inputs.span, inputs.span, ast.ty_nil);
}
- ret rec(effect=eff, proto=proto,
- inputs=inputs.node, output=output);
+ ret rec(effect=eff, inputs=inputs.node, output=output);
}
impure fn parse_fn(parser p, ast.effect eff, ast.proto proto) -> ast._fn {
- auto decl = parse_fn_decl(p, proto, eff);
+ auto decl = parse_fn_decl(p, eff);
auto body = parse_block(p);
ret rec(decl = decl,
+ proto = proto,
body = body);
}
impure fn parse_fn_header(parser p)
- -> tup(span, ast.proto, ast.ident, vec[ast.ty_param]) {
- auto lo = p.get_span();
- auto proto = parse_proto(p);
+ -> tup(ast.ident, vec[ast.ty_param]) {
auto id = parse_ident(p);
auto ty_params = parse_ty_params(p);
- ret tup(lo, proto, id, ty_params);
+ ret tup(id, ty_params);
}
impure fn parse_item_fn_or_iter(parser p, ast.effect eff) -> @ast.item {
+ auto lo = p.get_span();
+ auto proto = parse_proto(p);
auto t = parse_fn_header(p);
- auto f = parse_fn(p, eff, t._1);
- auto item = ast.item_fn(t._2, f, t._3,
+ auto f = parse_fn(p, eff, proto);
+ auto item = ast.item_fn(t._0, f, t._1,
p.next_def_id(), ast.ann_none);
- ret @spanned(t._0, f.body.span, item);
+ ret @spanned(lo, f.body.span, item);
}
@@ -1760,13 +1759,15 @@ impure fn parse_item_native_type(parser p) -> @ast.native_item {
}
impure fn parse_item_native_fn(parser p, ast.effect eff) -> @ast.native_item {
+ auto lo = p.get_span();
+ expect(p, token.FN);
auto t = parse_fn_header(p);
- auto decl = parse_fn_decl(p, t._1, eff);
+ auto decl = parse_fn_decl(p, eff);
auto hi = p.get_span();
expect(p, token.SEMI);
- auto item = ast.native_item_fn(t._2, decl, t._3, p.next_def_id(),
+ auto item = ast.native_item_fn(t._0, decl, t._1, p.next_def_id(),
ast.ann_none);
- ret @spanned(t._0, hi, item);
+ ret @spanned(lo, hi, item);
}
impure fn parse_native_item(parser p) -> @ast.native_item {
diff --git a/src/comp/middle/fold.rs b/src/comp/middle/fold.rs
index 968d4737..65bbe602 100644
--- a/src/comp/middle/fold.rs
+++ b/src/comp/middle/fold.rs
@@ -253,10 +253,11 @@ type ast_fold[ENV] =
&ast.block_) -> block) fold_block,
(fn(&ENV e, &fn_decl decl,
+ ast.proto proto,
&block body) -> ast._fn) fold_fn,
(fn(&ENV e, ast.effect effect,
- ast.proto proto, vec[arg] inputs,
+ vec[arg] inputs,
@ty output) -> ast.fn_decl) fold_fn_decl,
(fn(&ENV e, &ast._mod m) -> ast._mod) fold_mod,
@@ -757,7 +758,7 @@ fn fold_fn_decl[ENV](&ENV env, ast_fold[ENV] fld,
inputs += fold_arg(env, fld, a);
}
auto output = fold_ty[ENV](env, fld, decl.output);
- ret fld.fold_fn_decl(env, decl.effect, decl.proto, inputs, output);
+ ret fld.fold_fn_decl(env, decl.effect, inputs, output);
}
fn fold_fn[ENV](&ENV env, ast_fold[ENV] fld, &ast._fn f) -> ast._fn {
@@ -765,7 +766,7 @@ fn fold_fn[ENV](&ENV env, ast_fold[ENV] fld, &ast._fn f) -> ast._fn {
auto body = fold_block[ENV](env, fld, f.body);
- ret fld.fold_fn(env, decl, body);
+ ret fld.fold_fn(env, decl, f.proto, body);
}
@@ -1306,16 +1307,16 @@ fn identity_fold_block[ENV](&ENV e, &span sp, &ast.block_ blk) -> block {
fn identity_fold_fn_decl[ENV](&ENV e,
ast.effect effect,
- ast.proto proto,
vec[arg] inputs,
@ty output) -> ast.fn_decl {
- ret rec(effect=effect, proto=proto, inputs=inputs, output=output);
+ ret rec(effect=effect, inputs=inputs, output=output);
}
fn identity_fold_fn[ENV](&ENV e,
&fn_decl decl,
+ ast.proto proto,
&block body) -> ast._fn {
- ret rec(decl=decl, body=body);
+ ret rec(decl=decl, proto=proto, body=body);
}
fn identity_fold_mod[ENV](&ENV e, &ast._mod m) -> ast._mod {
@@ -1475,8 +1476,8 @@ fn new_identity_fold[ENV]() -> ast_fold[ENV] {
bind identity_fold_view_item_import[ENV](_,_,_,_,_,_),
fold_block = bind identity_fold_block[ENV](_,_,_),
- fold_fn = bind identity_fold_fn[ENV](_,_,_),
- fold_fn_decl = bind identity_fold_fn_decl[ENV](_,_,_,_,_),
+ fold_fn = bind identity_fold_fn[ENV](_,_,_,_),
+ fold_fn_decl = bind identity_fold_fn_decl[ENV](_,_,_,_),
fold_mod = bind identity_fold_mod[ENV](_,_),
fold_native_mod = bind identity_fold_native_mod[ENV](_,_),
fold_crate = bind identity_fold_crate[ENV](_,_,_),
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs
index 467aaa0d..33693835 100644
--- a/src/comp/middle/trans.rs
+++ b/src/comp/middle/trans.rs
@@ -4019,7 +4019,7 @@ fn trans_fn(@crate_ctxt cx, &ast._fn f, ast.def_id fid,
cx.item_names.insert(cx.path, llfndecl);
auto fcx = new_fn_ctxt(cx, cx.path, llfndecl);
- create_llargs_for_fn_args(fcx, f.decl.proto,
+ create_llargs_for_fn_args(fcx, f.proto,
ty_self, ret_ty_of_fn(ann),
f.decl.inputs, ty_params);
auto bcx = new_top_block_ctxt(fcx);
diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs
index 40fd0f15..db28735e 100644
--- a/src/comp/middle/typeck.rs
+++ b/src/comp/middle/typeck.rs
@@ -332,10 +332,11 @@ fn ty_of_fn_decl(@ty_item_table id_to_ty_item,
fn(&@ast.ty ast_ty) -> @ty.t convert,
fn(&ast.arg a) -> arg ty_of_arg,
&ast.fn_decl decl,
+ ast.proto proto,
ast.def_id def_id) -> @ty.t {
auto input_tys = _vec.map[ast.arg,arg](ty_of_arg, decl.inputs);
auto output_ty = convert(decl.output);
- auto t_fn = plain_ty(ty.ty_fn(decl.proto, input_tys, output_ty));
+ auto t_fn = plain_ty(ty.ty_fn(proto, input_tys, output_ty));
item_to_ty.insert(def_id, t_fn);
ret t_fn;
}
@@ -394,7 +395,7 @@ fn collect_item_types(session.session sess, @ast.crate crate)
auto f = bind ty_of_arg(id_to_ty_item, item_to_ty, _);
auto inputs = _vec.map[ast.arg,arg](f, m.node.meth.decl.inputs);
auto output = convert(m.node.meth.decl.output);
- ret rec(proto=m.node.meth.decl.proto, ident=m.node.ident,
+ ret rec(proto=m.node.meth.proto, ident=m.node.ident,
inputs=inputs, output=output);
}
@@ -446,7 +447,7 @@ fn collect_item_types(session.session sess, @ast.crate crate)
case (ast.item_fn(?ident, ?fn_info, _, ?def_id, _)) {
auto f = bind ty_of_arg(id_to_ty_item, item_to_ty, _);
ret ty_of_fn_decl(id_to_ty_item, item_to_ty, convert, f,
- fn_info.decl, def_id);
+ fn_info.decl, fn_info.proto, def_id);
}
case (ast.item_obj(?ident, ?obj_info, _, ?def_id, _)) {
@@ -2155,7 +2156,8 @@ fn check_const(&@crate_ctxt ccx, &span sp, ast.ident ident, @ast.ty t,
ret @fold.respan[ast.item_](sp, item);
}
-fn check_fn(&@crate_ctxt ccx, &ast.fn_decl decl, &ast.block body) -> ast._fn {
+fn check_fn(&@crate_ctxt ccx, &ast.fn_decl decl, ast.proto proto,
+ &ast.block body) -> ast._fn {
auto local_ty_table = @common.new_def_hash[@ty.t]();
// FIXME: duplicate work: the item annotation already has the arg types
@@ -2182,8 +2184,9 @@ fn check_fn(&@crate_ctxt ccx, &ast.fn_decl decl, &ast.block body) -> ast._fn {
auto block_t = check_block(fcx, body);
auto block_wb = writeback(fcx, block_t);
- auto fn_t = rec(decl=decl,
- body=block_wb);
+ auto fn_t = rec(decl=decl,
+ proto=proto,
+ body=block_wb);
ret fn_t;
}
@@ -2202,7 +2205,7 @@ fn check_item_fn(&@crate_ctxt ccx, &span sp, ast.ident ident, &ast._fn f,
}
auto output_ty = ast_ty_to_ty_crate(ccx, f.decl.output);
- auto fn_sty = ty.ty_fn(f.decl.proto, inputs, output_ty);
+ auto fn_sty = ty.ty_fn(f.proto, inputs, output_ty);
auto fn_ann = ast.ann_type(plain_ty(fn_sty));
auto item = ast.item_fn(ident, f, ty_params, id, fn_ann);
@@ -2234,7 +2237,7 @@ fn check_crate(session.session sess, @ast.crate crate) -> @ast.crate {
auto fld = fold.new_identity_fold[@crate_ctxt]();
fld = @rec(update_env_for_item = bind update_obj_fields(_, _),
- fold_fn = bind check_fn(_,_,_),
+ fold_fn = bind check_fn(_,_,_,_),
fold_item_fn = bind check_item_fn(_,_,_,_,_,_,_)
with *fld);
ret fold.fold_crate[@crate_ctxt](ccx, fld, result._0);