convert the remaining ast record types into structs
These are: region,arg,fn_decl,method,_mod,foreign_mod, variant_arg,enum_def_,variant_,trait_ref.
This commit is contained in:
parent
5ba7e55a4c
commit
d5d77b9351
17 changed files with 334 additions and 204 deletions
|
@ -361,7 +361,7 @@ mod test {
|
||||||
if with_bin { attrs += ~[make_crate_type_attr(~"bin")]; }
|
if with_bin { attrs += ~[make_crate_type_attr(~"bin")]; }
|
||||||
if with_lib { attrs += ~[make_crate_type_attr(~"lib")]; }
|
if with_lib { attrs += ~[make_crate_type_attr(~"lib")]; }
|
||||||
@ast_util::respan(ast_util::dummy_sp(), ast::crate_ {
|
@ast_util::respan(ast_util::dummy_sp(), ast::crate_ {
|
||||||
module: {view_items: ~[], items: ~[]},
|
module: ast::_mod { view_items: ~[], items: ~[] },
|
||||||
attrs: attrs,
|
attrs: attrs,
|
||||||
config: ~[]
|
config: ~[]
|
||||||
})
|
})
|
||||||
|
|
|
@ -67,15 +67,14 @@ fn filter_view_item(cx: ctxt, &&view_item: @ast::view_item
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_mod(cx: ctxt, m: ast::_mod, fld: fold::ast_fold) ->
|
fn fold_mod(cx: ctxt, m: ast::_mod, fld: fold::ast_fold) -> ast::_mod {
|
||||||
ast::_mod {
|
|
||||||
let filtered_items = vec::filter_map(m.items, |a| filter_item(cx, *a));
|
let filtered_items = vec::filter_map(m.items, |a| filter_item(cx, *a));
|
||||||
let filtered_view_items = vec::filter_map(m.view_items,
|
let filtered_view_items = vec::filter_map(m.view_items,
|
||||||
|a| filter_view_item(cx, *a));
|
|a| filter_view_item(cx, *a));
|
||||||
return {
|
ast::_mod {
|
||||||
view_items: vec::map(filtered_view_items, |x| fld.fold_view_item(*x)),
|
view_items: filtered_view_items.map(|x| fld.fold_view_item(*x)),
|
||||||
items: vec::filter_map(filtered_items, |x| fld.fold_item(*x))
|
items: filtered_items.filter_map(|x| fld.fold_item(*x)),
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn filter_foreign_item(cx: ctxt, &&item: @ast::foreign_item) ->
|
fn filter_foreign_item(cx: ctxt, &&item: @ast::foreign_item) ->
|
||||||
|
@ -85,18 +84,21 @@ fn filter_foreign_item(cx: ctxt, &&item: @ast::foreign_item) ->
|
||||||
} else { option::None }
|
} else { option::None }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_foreign_mod(cx: ctxt, nm: ast::foreign_mod,
|
fn fold_foreign_mod(
|
||||||
fld: fold::ast_fold) -> ast::foreign_mod {
|
cx: ctxt,
|
||||||
|
nm: ast::foreign_mod,
|
||||||
|
fld: fold::ast_fold
|
||||||
|
) -> ast::foreign_mod {
|
||||||
let filtered_items = vec::filter_map(nm.items,
|
let filtered_items = vec::filter_map(nm.items,
|
||||||
|a| filter_foreign_item(cx, *a));
|
|a| filter_foreign_item(cx, *a));
|
||||||
let filtered_view_items = vec::filter_map(nm.view_items,
|
let filtered_view_items = vec::filter_map(nm.view_items,
|
||||||
|a| filter_view_item(cx, *a));
|
|a| filter_view_item(cx, *a));
|
||||||
return {
|
ast::foreign_mod {
|
||||||
sort: nm.sort,
|
sort: nm.sort,
|
||||||
abi: nm.abi,
|
abi: nm.abi,
|
||||||
view_items: vec::map(filtered_view_items, |x| fld.fold_view_item(*x)),
|
view_items: vec::map(filtered_view_items, |x| fld.fold_view_item(*x)),
|
||||||
items: filtered_items
|
items: filtered_items
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_item_underscore(cx: ctxt, +item: ast::item_,
|
fn fold_item_underscore(cx: ctxt, +item: ast::item_,
|
||||||
|
|
|
@ -62,7 +62,7 @@ fn inject_libcore_ref(sess: Session,
|
||||||
};
|
};
|
||||||
|
|
||||||
let vis = vec::append(~[vi1], crate.module.view_items);
|
let vis = vec::append(~[vi1], crate.module.view_items);
|
||||||
let mut new_module = {
|
let mut new_module = ast::_mod {
|
||||||
view_items: vis,
|
view_items: vis,
|
||||||
../*bad*/copy crate.module
|
../*bad*/copy crate.module
|
||||||
};
|
};
|
||||||
|
@ -95,7 +95,7 @@ fn inject_libcore_ref(sess: Session,
|
||||||
let vis = vec::append(~[vi2], module.view_items);
|
let vis = vec::append(~[vi2], module.view_items);
|
||||||
|
|
||||||
// FIXME #2543: Bad copy.
|
// FIXME #2543: Bad copy.
|
||||||
let new_module = { view_items: vis, ..copy module };
|
let new_module = ast::_mod { view_items: vis, ..copy module };
|
||||||
fold::noop_fold_mod(new_module, fld)
|
fold::noop_fold_mod(new_module, fld)
|
||||||
},
|
},
|
||||||
..*fold::default_ast_fold()
|
..*fold::default_ast_fold()
|
||||||
|
|
|
@ -38,7 +38,7 @@ fn inject_intrinsic(sess: Session, crate: @ast::crate) -> @ast::crate {
|
||||||
|
|
||||||
@ast::spanned {
|
@ast::spanned {
|
||||||
node: ast::crate_ {
|
node: ast::crate_ {
|
||||||
module: {
|
module: ast::_mod {
|
||||||
items: items,
|
items: items,
|
||||||
.. /*bad*/copy crate.node.module
|
.. /*bad*/copy crate.node.module
|
||||||
},
|
},
|
||||||
|
|
|
@ -97,10 +97,12 @@ fn fold_mod(cx: test_ctxt, m: ast::_mod, fld: fold::ast_fold) -> ast::_mod {
|
||||||
} else { item }
|
} else { item }
|
||||||
}
|
}
|
||||||
|
|
||||||
let mod_nomain =
|
let mod_nomain = ast::_mod {
|
||||||
{view_items: /*bad*/copy m.view_items,
|
view_items: /*bad*/copy m.view_items,
|
||||||
items: vec::map(m.items, |i| nomain(cx, *i))};
|
items: vec::map(m.items, |i| nomain(cx, *i)),
|
||||||
return fold::noop_fold_mod(mod_nomain, fld);
|
};
|
||||||
|
|
||||||
|
fold::noop_fold_mod(mod_nomain, fld)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_crate(cx: test_ctxt, c: ast::crate_, fld: fold::ast_fold) ->
|
fn fold_crate(cx: test_ctxt, c: ast::crate_, fld: fold::ast_fold) ->
|
||||||
|
@ -182,7 +184,10 @@ fn should_fail(i: @ast::item) -> bool {
|
||||||
|
|
||||||
fn add_test_module(cx: test_ctxt, +m: ast::_mod) -> ast::_mod {
|
fn add_test_module(cx: test_ctxt, +m: ast::_mod) -> ast::_mod {
|
||||||
let testmod = mk_test_module(cx);
|
let testmod = mk_test_module(cx);
|
||||||
return {items: vec::append_one(/*bad*/copy m.items, testmod),.. m};
|
ast::_mod {
|
||||||
|
items: vec::append_one(/*bad*/copy m.items, testmod),
|
||||||
|
.. m
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -213,8 +218,9 @@ fn mk_test_module(cx: test_ctxt) -> @ast::item {
|
||||||
// The synthesized main function which will call the console test runner
|
// The synthesized main function which will call the console test runner
|
||||||
// with our list of tests
|
// with our list of tests
|
||||||
let mainfn = mk_main(cx);
|
let mainfn = mk_main(cx);
|
||||||
let testmod: ast::_mod = {
|
let testmod = ast::_mod {
|
||||||
view_items: view_items, items: ~[mainfn, testsfn]
|
view_items: view_items,
|
||||||
|
items: ~[mainfn, testsfn],
|
||||||
};
|
};
|
||||||
let item_ = ast::item_mod(testmod);
|
let item_ = ast::item_mod(testmod);
|
||||||
// This attribute tells resolve to let us call unexported functions
|
// This attribute tells resolve to let us call unexported functions
|
||||||
|
@ -276,10 +282,11 @@ fn mk_std(cx: test_ctxt) -> @ast::view_item {
|
||||||
fn mk_tests(cx: test_ctxt) -> @ast::item {
|
fn mk_tests(cx: test_ctxt) -> @ast::item {
|
||||||
let ret_ty = mk_test_desc_vec_ty(cx);
|
let ret_ty = mk_test_desc_vec_ty(cx);
|
||||||
|
|
||||||
let decl: ast::fn_decl =
|
let decl = ast::fn_decl {
|
||||||
{inputs: ~[],
|
inputs: ~[],
|
||||||
output: ret_ty,
|
output: ret_ty,
|
||||||
cf: ast::return_val};
|
cf: ast::return_val,
|
||||||
|
};
|
||||||
|
|
||||||
// The vector of test_descs for this crate
|
// The vector of test_descs for this crate
|
||||||
let test_descs = mk_test_desc_vec(cx);
|
let test_descs = mk_test_desc_vec(cx);
|
||||||
|
@ -486,7 +493,7 @@ fn mk_test_wrapper(cx: test_ctxt,
|
||||||
let call_stmt: ast::stmt = nospan(
|
let call_stmt: ast::stmt = nospan(
|
||||||
ast::stmt_semi(@call_expr, cx.sess.next_node_id()));
|
ast::stmt_semi(@call_expr, cx.sess.next_node_id()));
|
||||||
|
|
||||||
let wrapper_decl: ast::fn_decl = {
|
let wrapper_decl = ast::fn_decl {
|
||||||
inputs: ~[],
|
inputs: ~[],
|
||||||
output: @ast::Ty {
|
output: @ast::Ty {
|
||||||
id: cx.sess.next_node_id(),
|
id: cx.sess.next_node_id(),
|
||||||
|
@ -521,10 +528,11 @@ fn mk_main(cx: test_ctxt) -> @ast::item {
|
||||||
span: dummy_sp(),
|
span: dummy_sp(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let decl: ast::fn_decl =
|
let decl = ast::fn_decl {
|
||||||
{inputs: ~[],
|
inputs: ~[],
|
||||||
output: @ret_ty,
|
output: @ret_ty,
|
||||||
cf: ast::return_val};
|
cf: ast::return_val,
|
||||||
|
};
|
||||||
|
|
||||||
let test_main_call_expr = mk_test_main_call(cx);
|
let test_main_call_expr = mk_test_main_call(cx);
|
||||||
|
|
||||||
|
|
|
@ -1842,13 +1842,17 @@ fn trans_enum_variant(ccx: @crate_ctxt,
|
||||||
llfndecl: ValueRef) {
|
llfndecl: ValueRef) {
|
||||||
let _icx = ccx.insn_ctxt("trans_enum_variant");
|
let _icx = ccx.insn_ctxt("trans_enum_variant");
|
||||||
// Translate variant arguments to function arguments.
|
// Translate variant arguments to function arguments.
|
||||||
let fn_args = vec::map(args, |varg|
|
let fn_args = do args.map |varg| {
|
||||||
{mode: ast::expl(ast::by_copy),
|
ast::arg {
|
||||||
ty: varg.ty,
|
mode: ast::expl(ast::by_copy),
|
||||||
pat: ast_util::ident_to_pat(ccx.tcx.sess.next_node_id(),
|
ty: varg.ty,
|
||||||
ast_util::dummy_sp(),
|
pat: ast_util::ident_to_pat(
|
||||||
special_idents::arg),
|
ccx.tcx.sess.next_node_id(),
|
||||||
id: varg.id});
|
ast_util::dummy_sp(),
|
||||||
|
special_idents::arg),
|
||||||
|
id: varg.id,
|
||||||
|
}
|
||||||
|
};
|
||||||
// XXX: Bad copy of `param_substs`.
|
// XXX: Bad copy of `param_substs`.
|
||||||
let fcx = new_fn_ctxt_w_id(ccx, ~[], llfndecl, variant.node.id, None,
|
let fcx = new_fn_ctxt_w_id(ccx, ~[], llfndecl, variant.node.id, None,
|
||||||
copy param_substs, None);
|
copy param_substs, None);
|
||||||
|
@ -1902,7 +1906,7 @@ fn trans_tuple_struct(ccx: @crate_ctxt,
|
||||||
|
|
||||||
// Translate struct fields to function arguments.
|
// Translate struct fields to function arguments.
|
||||||
let fn_args = do fields.map |field| {
|
let fn_args = do fields.map |field| {
|
||||||
{
|
ast::arg {
|
||||||
mode: ast::expl(ast::by_copy),
|
mode: ast::expl(ast::by_copy),
|
||||||
ty: field.node.ty,
|
ty: field.node.ty,
|
||||||
pat: ast_util::ident_to_pat(ccx.tcx.sess.next_node_id(),
|
pat: ast_util::ident_to_pat(ccx.tcx.sess.next_node_id(),
|
||||||
|
|
|
@ -96,7 +96,7 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint)
|
||||||
match map_node {
|
match map_node {
|
||||||
ast_map::node_item(@ast::item { node: item_fn(_, _, _, ref body),
|
ast_map::node_item(@ast::item { node: item_fn(_, _, _, ref body),
|
||||||
_ }, _) |
|
_ }, _) |
|
||||||
ast_map::node_method(@{body: ref body, _}, _, _) => {
|
ast_map::node_method(@ast::method {body: ref body, _}, _, _) => {
|
||||||
handle_body(cx, (*body));
|
handle_body(cx, (*body));
|
||||||
}
|
}
|
||||||
ast_map::node_trait_method(*) => {
|
ast_map::node_trait_method(*) => {
|
||||||
|
|
|
@ -1107,7 +1107,10 @@ impl prim_ty : cmp::Eq {
|
||||||
|
|
||||||
#[auto_encode]
|
#[auto_encode]
|
||||||
#[auto_decode]
|
#[auto_decode]
|
||||||
type region = {id: node_id, node: region_};
|
struct region {
|
||||||
|
id: node_id,
|
||||||
|
node: region_,
|
||||||
|
}
|
||||||
|
|
||||||
#[auto_encode]
|
#[auto_encode]
|
||||||
#[auto_decode]
|
#[auto_decode]
|
||||||
|
@ -1194,14 +1197,20 @@ impl Ty : to_bytes::IterBytes {
|
||||||
|
|
||||||
#[auto_encode]
|
#[auto_encode]
|
||||||
#[auto_decode]
|
#[auto_decode]
|
||||||
type arg = {mode: mode, ty: @Ty, pat: @pat, id: node_id};
|
struct arg {
|
||||||
|
mode: mode,
|
||||||
|
ty: @Ty,
|
||||||
|
pat: @pat,
|
||||||
|
id: node_id,
|
||||||
|
}
|
||||||
|
|
||||||
#[auto_encode]
|
#[auto_encode]
|
||||||
#[auto_decode]
|
#[auto_decode]
|
||||||
type fn_decl =
|
struct fn_decl {
|
||||||
{inputs: ~[arg],
|
inputs: ~[arg],
|
||||||
output: @Ty,
|
output: @Ty,
|
||||||
cf: ret_style};
|
cf: ret_style,
|
||||||
|
}
|
||||||
|
|
||||||
#[auto_encode]
|
#[auto_encode]
|
||||||
#[auto_decode]
|
#[auto_decode]
|
||||||
|
@ -1321,15 +1330,26 @@ type self_ty = spanned<self_ty_>;
|
||||||
|
|
||||||
#[auto_encode]
|
#[auto_encode]
|
||||||
#[auto_decode]
|
#[auto_decode]
|
||||||
type method = {ident: ident, attrs: ~[attribute],
|
struct method {
|
||||||
tps: ~[ty_param], self_ty: self_ty,
|
ident: ident,
|
||||||
purity: purity, decl: fn_decl, body: blk,
|
attrs: ~[attribute],
|
||||||
id: node_id, span: span, self_id: node_id,
|
tps: ~[ty_param],
|
||||||
vis: visibility};
|
self_ty: self_ty,
|
||||||
|
purity: purity,
|
||||||
|
decl: fn_decl,
|
||||||
|
body: blk,
|
||||||
|
id: node_id,
|
||||||
|
span: span,
|
||||||
|
self_id: node_id,
|
||||||
|
vis: visibility,
|
||||||
|
}
|
||||||
|
|
||||||
#[auto_encode]
|
#[auto_encode]
|
||||||
#[auto_decode]
|
#[auto_decode]
|
||||||
type _mod = {view_items: ~[@view_item], items: ~[@item]};
|
struct _mod {
|
||||||
|
view_items: ~[@view_item],
|
||||||
|
items: ~[@item],
|
||||||
|
}
|
||||||
|
|
||||||
#[auto_encode]
|
#[auto_encode]
|
||||||
#[auto_decode]
|
#[auto_decode]
|
||||||
|
@ -1367,15 +1387,19 @@ impl foreign_abi : cmp::Eq {
|
||||||
|
|
||||||
#[auto_encode]
|
#[auto_encode]
|
||||||
#[auto_decode]
|
#[auto_decode]
|
||||||
type foreign_mod =
|
struct foreign_mod {
|
||||||
{sort: foreign_mod_sort,
|
sort: foreign_mod_sort,
|
||||||
abi: ident,
|
abi: ident,
|
||||||
view_items: ~[@view_item],
|
view_items: ~[@view_item],
|
||||||
items: ~[@foreign_item]};
|
items: ~[@foreign_item],
|
||||||
|
}
|
||||||
|
|
||||||
#[auto_encode]
|
#[auto_encode]
|
||||||
#[auto_decode]
|
#[auto_decode]
|
||||||
type variant_arg = {ty: @Ty, id: node_id};
|
struct variant_arg {
|
||||||
|
ty: @Ty,
|
||||||
|
id: node_id,
|
||||||
|
}
|
||||||
|
|
||||||
#[auto_encode]
|
#[auto_encode]
|
||||||
#[auto_decode]
|
#[auto_decode]
|
||||||
|
@ -1387,7 +1411,10 @@ enum variant_kind {
|
||||||
|
|
||||||
#[auto_encode]
|
#[auto_encode]
|
||||||
#[auto_decode]
|
#[auto_decode]
|
||||||
type enum_def_ = { variants: ~[variant], common: Option<@struct_def> };
|
struct enum_def_ {
|
||||||
|
variants: ~[variant],
|
||||||
|
common: Option<@struct_def>,
|
||||||
|
}
|
||||||
|
|
||||||
#[auto_encode]
|
#[auto_encode]
|
||||||
#[auto_decode]
|
#[auto_decode]
|
||||||
|
@ -1395,8 +1422,14 @@ enum enum_def = enum_def_;
|
||||||
|
|
||||||
#[auto_encode]
|
#[auto_encode]
|
||||||
#[auto_decode]
|
#[auto_decode]
|
||||||
type variant_ = {name: ident, attrs: ~[attribute], kind: variant_kind,
|
struct variant_ {
|
||||||
id: node_id, disr_expr: Option<@expr>, vis: visibility};
|
name: ident,
|
||||||
|
attrs: ~[attribute],
|
||||||
|
kind: variant_kind,
|
||||||
|
id: node_id,
|
||||||
|
disr_expr: Option<@expr>,
|
||||||
|
vis: visibility,
|
||||||
|
}
|
||||||
|
|
||||||
type variant = spanned<variant_>;
|
type variant = spanned<variant_>;
|
||||||
|
|
||||||
|
@ -1492,7 +1525,10 @@ struct attribute_ {
|
||||||
*/
|
*/
|
||||||
#[auto_encode]
|
#[auto_encode]
|
||||||
#[auto_decode]
|
#[auto_decode]
|
||||||
type trait_ref = {path: @path, ref_id: node_id};
|
struct trait_ref {
|
||||||
|
path: @path,
|
||||||
|
ref_id: node_id,
|
||||||
|
}
|
||||||
|
|
||||||
#[auto_encode]
|
#[auto_encode]
|
||||||
#[auto_decode]
|
#[auto_decode]
|
||||||
|
|
|
@ -443,8 +443,11 @@ fn operator_prec(op: ast::binop) -> uint {
|
||||||
fn dtor_dec() -> fn_decl {
|
fn dtor_dec() -> fn_decl {
|
||||||
let nil_t = @ast::Ty { id: 0, node: ty_nil, span: dummy_sp() };
|
let nil_t = @ast::Ty { id: 0, node: ty_nil, span: dummy_sp() };
|
||||||
// dtor has no args
|
// dtor has no args
|
||||||
{inputs: ~[],
|
ast::fn_decl {
|
||||||
output: nil_t, cf: return_val}
|
inputs: ~[],
|
||||||
|
output: nil_t,
|
||||||
|
cf: return_val,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ______________________________________________________________________
|
// ______________________________________________________________________
|
||||||
|
|
|
@ -462,7 +462,7 @@ fn mk_impl(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
let opt_trait = Some(@{
|
let opt_trait = Some(@ast::trait_ref {
|
||||||
path: path,
|
path: path,
|
||||||
ref_id: cx.next_id(),
|
ref_id: cx.next_id(),
|
||||||
});
|
});
|
||||||
|
@ -581,7 +581,7 @@ fn mk_ser_method(
|
||||||
let ty_s = @ast::Ty {
|
let ty_s = @ast::Ty {
|
||||||
id: cx.next_id(),
|
id: cx.next_id(),
|
||||||
node: ast::ty_rptr(
|
node: ast::ty_rptr(
|
||||||
@{
|
@ast::region {
|
||||||
id: cx.next_id(),
|
id: cx.next_id(),
|
||||||
node: ast::re_anon,
|
node: ast::re_anon,
|
||||||
},
|
},
|
||||||
|
@ -593,7 +593,7 @@ fn mk_ser_method(
|
||||||
span: span,
|
span: span,
|
||||||
};
|
};
|
||||||
|
|
||||||
let ser_inputs = ~[{
|
let ser_inputs = ~[ast::arg {
|
||||||
mode: ast::infer(cx.next_id()),
|
mode: ast::infer(cx.next_id()),
|
||||||
ty: ty_s,
|
ty: ty_s,
|
||||||
pat: @ast::pat {
|
pat: @ast::pat {
|
||||||
|
@ -613,13 +613,13 @@ fn mk_ser_method(
|
||||||
span: span,
|
span: span,
|
||||||
};
|
};
|
||||||
|
|
||||||
let ser_decl = {
|
let ser_decl = ast::fn_decl {
|
||||||
inputs: ser_inputs,
|
inputs: ser_inputs,
|
||||||
output: ser_output,
|
output: ser_output,
|
||||||
cf: ast::return_val,
|
cf: ast::return_val,
|
||||||
};
|
};
|
||||||
|
|
||||||
@{
|
@ast::method {
|
||||||
ident: cx.ident_of(~"encode"),
|
ident: cx.ident_of(~"encode"),
|
||||||
attrs: ~[],
|
attrs: ~[],
|
||||||
tps: ~[],
|
tps: ~[],
|
||||||
|
@ -644,7 +644,7 @@ fn mk_deser_method(
|
||||||
let ty_d = @ast::Ty {
|
let ty_d = @ast::Ty {
|
||||||
id: cx.next_id(),
|
id: cx.next_id(),
|
||||||
node: ast::ty_rptr(
|
node: ast::ty_rptr(
|
||||||
@{
|
@ast::region {
|
||||||
id: cx.next_id(),
|
id: cx.next_id(),
|
||||||
node: ast::re_anon,
|
node: ast::re_anon,
|
||||||
},
|
},
|
||||||
|
@ -656,7 +656,7 @@ fn mk_deser_method(
|
||||||
span: span,
|
span: span,
|
||||||
};
|
};
|
||||||
|
|
||||||
let deser_inputs = ~[{
|
let deser_inputs = ~[ast::arg {
|
||||||
mode: ast::infer(cx.next_id()),
|
mode: ast::infer(cx.next_id()),
|
||||||
ty: ty_d,
|
ty: ty_d,
|
||||||
pat: @ast::pat {
|
pat: @ast::pat {
|
||||||
|
@ -670,13 +670,13 @@ fn mk_deser_method(
|
||||||
id: cx.next_id(),
|
id: cx.next_id(),
|
||||||
}];
|
}];
|
||||||
|
|
||||||
let deser_decl = {
|
let deser_decl = ast::fn_decl {
|
||||||
inputs: deser_inputs,
|
inputs: deser_inputs,
|
||||||
output: ty,
|
output: ty,
|
||||||
cf: ast::return_val,
|
cf: ast::return_val,
|
||||||
};
|
};
|
||||||
|
|
||||||
@{
|
@ast::method {
|
||||||
ident: cx.ident_of(~"decode"),
|
ident: cx.ident_of(~"decode"),
|
||||||
attrs: ~[],
|
attrs: ~[],
|
||||||
tps: ~[],
|
tps: ~[],
|
||||||
|
@ -1187,8 +1187,8 @@ fn mk_enum_deser_body(
|
||||||
let expr_lambda = cx.expr(
|
let expr_lambda = cx.expr(
|
||||||
span,
|
span,
|
||||||
ast::expr_fn_block(
|
ast::expr_fn_block(
|
||||||
{
|
ast::fn_decl {
|
||||||
inputs: ~[{
|
inputs: ~[ast::arg {
|
||||||
mode: ast::infer(cx.next_id()),
|
mode: ast::infer(cx.next_id()),
|
||||||
ty: @ast::Ty {
|
ty: @ast::Ty {
|
||||||
id: cx.next_id(),
|
id: cx.next_id(),
|
||||||
|
|
|
@ -317,7 +317,7 @@ fn mk_arg(cx: ext_ctxt,
|
||||||
ty: @ast::Ty)
|
ty: @ast::Ty)
|
||||||
-> ast::arg {
|
-> ast::arg {
|
||||||
let arg_pat = mk_pat_ident(cx, span, ident);
|
let arg_pat = mk_pat_ident(cx, span, ident);
|
||||||
{
|
ast::arg {
|
||||||
mode: ast::infer(cx.next_id()),
|
mode: ast::infer(cx.next_id()),
|
||||||
ty: ty,
|
ty: ty,
|
||||||
pat: arg_pat,
|
pat: arg_pat,
|
||||||
|
@ -325,7 +325,7 @@ fn mk_arg(cx: ext_ctxt,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn mk_fn_decl(+inputs: ~[ast::arg], output: @ast::Ty) -> ast::fn_decl {
|
fn mk_fn_decl(+inputs: ~[ast::arg], output: @ast::Ty) -> ast::fn_decl {
|
||||||
{ inputs: move inputs, output: output, cf: ast::return_val }
|
ast::fn_decl { inputs: inputs, output: output, cf: ast::return_val }
|
||||||
}
|
}
|
||||||
fn mk_ty_param(cx: ext_ctxt,
|
fn mk_ty_param(cx: ext_ctxt,
|
||||||
ident: ast::ident,
|
ident: ast::ident,
|
||||||
|
|
|
@ -135,7 +135,7 @@ fn create_eq_method(cx: ext_ctxt,
|
||||||
span,
|
span,
|
||||||
type_ident,
|
type_ident,
|
||||||
ty_params);
|
ty_params);
|
||||||
let arg_region = @{ id: cx.next_id(), node: re_anon };
|
let arg_region = @ast::region { id: cx.next_id(), node: re_anon };
|
||||||
let arg_type = ty_rptr(
|
let arg_type = ty_rptr(
|
||||||
arg_region,
|
arg_region,
|
||||||
ast::mt { ty: arg_path_type, mutbl: m_imm }
|
ast::mt { ty: arg_path_type, mutbl: m_imm }
|
||||||
|
@ -168,7 +168,7 @@ fn create_eq_method(cx: ext_ctxt,
|
||||||
|
|
||||||
// Create the method.
|
// Create the method.
|
||||||
let self_ty = spanned { node: sty_region(m_imm), span: span };
|
let self_ty = spanned { node: sty_region(m_imm), span: span };
|
||||||
return @{
|
@ast::method {
|
||||||
ident: method_ident,
|
ident: method_ident,
|
||||||
attrs: ~[],
|
attrs: ~[],
|
||||||
tps: ~[],
|
tps: ~[],
|
||||||
|
@ -180,7 +180,7 @@ fn create_eq_method(cx: ext_ctxt,
|
||||||
span: span,
|
span: span,
|
||||||
self_id: cx.next_id(),
|
self_id: cx.next_id(),
|
||||||
vis: public
|
vis: public
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_self_type_with_params(cx: ext_ctxt,
|
fn create_self_type_with_params(cx: ext_ctxt,
|
||||||
|
@ -234,7 +234,7 @@ fn create_derived_impl(cx: ext_ctxt,
|
||||||
types: ~[]
|
types: ~[]
|
||||||
};
|
};
|
||||||
let trait_path = @move trait_path;
|
let trait_path = @move trait_path;
|
||||||
let trait_ref = {
|
let trait_ref = ast::trait_ref {
|
||||||
path: trait_path,
|
path: trait_path,
|
||||||
ref_id: cx.next_id()
|
ref_id: cx.next_id()
|
||||||
};
|
};
|
||||||
|
@ -319,7 +319,7 @@ fn create_iter_bytes_method(cx: ext_ctxt,
|
||||||
// Create the method.
|
// Create the method.
|
||||||
let self_ty = spanned { node: sty_region(m_imm), span: span };
|
let self_ty = spanned { node: sty_region(m_imm), span: span };
|
||||||
let method_ident = cx.ident_of(~"iter_bytes");
|
let method_ident = cx.ident_of(~"iter_bytes");
|
||||||
return @{
|
@ast::method {
|
||||||
ident: method_ident,
|
ident: method_ident,
|
||||||
attrs: ~[],
|
attrs: ~[],
|
||||||
tps: ~[],
|
tps: ~[],
|
||||||
|
|
|
@ -119,7 +119,7 @@ fn expand_mod_items(exts: HashMap<~str, syntax_extension>, cx: ext_ctxt,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return {items: new_items, ..module_};
|
ast::_mod { items: new_items, ..module_ }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -198,7 +198,7 @@ impl ext_ctxt: ext_ctxt_ast_builder {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn arg(name: ident, ty: @ast::Ty) -> ast::arg {
|
fn arg(name: ident, ty: @ast::Ty) -> ast::arg {
|
||||||
{
|
ast::arg {
|
||||||
mode: ast::infer(self.next_id()),
|
mode: ast::infer(self.next_id()),
|
||||||
ty: ty,
|
ty: ty,
|
||||||
pat: @ast::pat {
|
pat: @ast::pat {
|
||||||
|
@ -231,9 +231,11 @@ impl ext_ctxt: ext_ctxt_ast_builder {
|
||||||
|
|
||||||
fn fn_decl(+inputs: ~[ast::arg],
|
fn fn_decl(+inputs: ~[ast::arg],
|
||||||
output: @ast::Ty) -> ast::fn_decl {
|
output: @ast::Ty) -> ast::fn_decl {
|
||||||
{inputs: inputs,
|
ast::fn_decl {
|
||||||
output: output,
|
inputs: inputs,
|
||||||
cf: ast::return_val}
|
output: output,
|
||||||
|
cf: ast::return_val,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn item(name: ident,
|
fn item(name: ident,
|
||||||
|
@ -295,15 +297,20 @@ impl ext_ctxt: ext_ctxt_ast_builder {
|
||||||
fn variant(name: ident,
|
fn variant(name: ident,
|
||||||
span: span,
|
span: span,
|
||||||
+tys: ~[@ast::Ty]) -> ast::variant {
|
+tys: ~[@ast::Ty]) -> ast::variant {
|
||||||
let args = tys.map(|ty| {ty: *ty, id: self.next_id()});
|
let args = do tys.map |ty| {
|
||||||
|
ast::variant_arg { ty: *ty, id: self.next_id() }
|
||||||
|
};
|
||||||
|
|
||||||
spanned { node: { name: name,
|
spanned {
|
||||||
attrs: ~[],
|
node: ast::variant_ {
|
||||||
kind: ast::tuple_variant_kind(args),
|
name: name,
|
||||||
id: self.next_id(),
|
attrs: ~[],
|
||||||
disr_expr: None,
|
kind: ast::tuple_variant_kind(args),
|
||||||
vis: ast::public},
|
id: self.next_id(),
|
||||||
span: span}
|
disr_expr: None,
|
||||||
|
vis: ast::public},
|
||||||
|
span: span,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn item_mod(name: ident,
|
fn item_mod(name: ident,
|
||||||
|
@ -336,11 +343,14 @@ impl ext_ctxt: ext_ctxt_ast_builder {
|
||||||
span: ast_util::dummy_sp()
|
span: ast_util::dummy_sp()
|
||||||
};
|
};
|
||||||
|
|
||||||
self.item(name,
|
self.item(
|
||||||
span,
|
name,
|
||||||
ast::item_mod({
|
span,
|
||||||
view_items: ~[vi],
|
ast::item_mod(ast::_mod {
|
||||||
items: items}))
|
view_items: ~[vi],
|
||||||
|
items: items,
|
||||||
|
})
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ty_path_ast_builder(path: @ast::path) -> @ast::Ty {
|
fn ty_path_ast_builder(path: @ast::path) -> @ast::Ty {
|
||||||
|
|
|
@ -240,11 +240,16 @@ impl state: to_type_decls {
|
||||||
items_msg.push(v);
|
items_msg.push(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
~[cx.item_enum_poly(name,
|
~[
|
||||||
self.span,
|
cx.item_enum_poly(
|
||||||
ast::enum_def({ variants: items_msg,
|
name,
|
||||||
common: None }),
|
self.span,
|
||||||
self.ty_params)]
|
ast::enum_def(enum_def_ {
|
||||||
|
variants: items_msg,
|
||||||
|
common: None }),
|
||||||
|
self.ty_params
|
||||||
|
)
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_endpoint_decls(cx: ext_ctxt, dir: direction) -> ~[@ast::item] {
|
fn to_endpoint_decls(cx: ext_ctxt, dir: direction) -> ~[@ast::item] {
|
||||||
|
|
|
@ -125,10 +125,12 @@ fn fold_attribute_(at: attribute, fld: ast_fold) -> attribute {
|
||||||
}
|
}
|
||||||
//used in noop_fold_foreign_item and noop_fold_fn_decl
|
//used in noop_fold_foreign_item and noop_fold_fn_decl
|
||||||
fn fold_arg_(a: arg, fld: ast_fold) -> arg {
|
fn fold_arg_(a: arg, fld: ast_fold) -> arg {
|
||||||
return {mode: a.mode,
|
ast::arg {
|
||||||
ty: fld.fold_ty(a.ty),
|
mode: a.mode,
|
||||||
pat: fld.fold_pat(a.pat),
|
ty: fld.fold_ty(a.ty),
|
||||||
id: fld.new_id(a.id)};
|
pat: fld.fold_pat(a.pat),
|
||||||
|
id: fld.new_id(a.id),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//used in noop_fold_expr, and possibly elsewhere in the future
|
//used in noop_fold_expr, and possibly elsewhere in the future
|
||||||
fn fold_mac_(m: mac, fld: ast_fold) -> mac {
|
fn fold_mac_(m: mac, fld: ast_fold) -> mac {
|
||||||
|
@ -139,9 +141,11 @@ fn fold_mac_(m: mac, fld: ast_fold) -> mac {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_fn_decl(decl: ast::fn_decl, fld: ast_fold) -> ast::fn_decl {
|
fn fold_fn_decl(decl: ast::fn_decl, fld: ast_fold) -> ast::fn_decl {
|
||||||
return {inputs: vec::map(decl.inputs, |x| fold_arg_(*x, fld) ),
|
ast::fn_decl {
|
||||||
output: fld.fold_ty(decl.output),
|
inputs: decl.inputs.map(|x| fold_arg_(*x, fld)),
|
||||||
cf: decl.cf}
|
output: fld.fold_ty(decl.output),
|
||||||
|
cf: decl.cf,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_ty_param_bound(tpb: ty_param_bound, fld: ast_fold) -> ty_param_bound {
|
fn fold_ty_param_bound(tpb: ty_param_bound, fld: ast_fold) -> ty_param_bound {
|
||||||
|
@ -189,7 +193,7 @@ fn noop_fold_foreign_item(&&ni: @foreign_item, fld: ast_fold)
|
||||||
match ni.node {
|
match ni.node {
|
||||||
foreign_item_fn(fdec, purity, typms) => {
|
foreign_item_fn(fdec, purity, typms) => {
|
||||||
foreign_item_fn(
|
foreign_item_fn(
|
||||||
{
|
ast::fn_decl {
|
||||||
inputs: fdec.inputs.map(|a| fold_arg(*a)),
|
inputs: fdec.inputs.map(|a| fold_arg(*a)),
|
||||||
output: fld.fold_ty(fdec.output),
|
output: fld.fold_ty(fdec.output),
|
||||||
cf: fdec.cf,
|
cf: fdec.cf,
|
||||||
|
@ -240,11 +244,11 @@ fn noop_fold_item_underscore(i: item_, fld: ast_fold) -> item_ {
|
||||||
item_ty(t, typms) => item_ty(fld.fold_ty(t),
|
item_ty(t, typms) => item_ty(fld.fold_ty(t),
|
||||||
fold_ty_params(typms, fld)),
|
fold_ty_params(typms, fld)),
|
||||||
item_enum(ref enum_definition, typms) => {
|
item_enum(ref enum_definition, typms) => {
|
||||||
item_enum(ast::enum_def({
|
item_enum(ast::enum_def(ast::enum_def_ {
|
||||||
variants: vec::map((*enum_definition).variants,
|
variants: enum_definition.variants.map(
|
||||||
|x| fld.fold_variant(*x)),
|
|x| fld.fold_variant(*x)),
|
||||||
common: option::map(&(*enum_definition).common,
|
common: enum_definition.common.map(
|
||||||
|x| fold_struct_def(*x, fld))
|
|x| fold_struct_def(*x, fld)),
|
||||||
}), fold_ty_params(typms, fld))
|
}), fold_ty_params(typms, fld))
|
||||||
}
|
}
|
||||||
item_struct(struct_def, typms) => {
|
item_struct(struct_def, typms) => {
|
||||||
|
@ -285,15 +289,18 @@ fn fold_struct_def(struct_def: @ast::struct_def, fld: ast_fold)
|
||||||
.. dtor.node},
|
.. dtor.node},
|
||||||
span: dtor.span }
|
span: dtor.span }
|
||||||
};
|
};
|
||||||
return @ast::struct_def {
|
@ast::struct_def {
|
||||||
fields: vec::map(struct_def.fields, |f| fold_struct_field(*f, fld)),
|
fields: struct_def.fields.map(|f| fold_struct_field(*f, fld)),
|
||||||
dtor: dtor,
|
dtor: dtor,
|
||||||
ctor_id: option::map(&struct_def.ctor_id, |cid| fld.new_id(*cid))
|
ctor_id: struct_def.ctor_id.map(|cid| fld.new_id(*cid)),
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_trait_ref(&&p: @trait_ref, fld: ast_fold) -> @trait_ref {
|
fn fold_trait_ref(&&p: @trait_ref, fld: ast_fold) -> @trait_ref {
|
||||||
@{path: fld.fold_path(p.path), ref_id: fld.new_id(p.ref_id)}
|
@ast::trait_ref {
|
||||||
|
path: fld.fold_path(p.path),
|
||||||
|
ref_id: fld.new_id(p.ref_id),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_struct_field(&&f: @struct_field, fld: ast_fold) -> @struct_field {
|
fn fold_struct_field(&&f: @struct_field, fld: ast_fold) -> @struct_field {
|
||||||
|
@ -304,17 +311,19 @@ fn fold_struct_field(&&f: @struct_field, fld: ast_fold) -> @struct_field {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn noop_fold_method(&&m: @method, fld: ast_fold) -> @method {
|
fn noop_fold_method(&&m: @method, fld: ast_fold) -> @method {
|
||||||
return @{ident: fld.fold_ident(m.ident),
|
@ast::method {
|
||||||
attrs: /* FIXME (#2543) */ copy m.attrs,
|
ident: fld.fold_ident(m.ident),
|
||||||
tps: fold_ty_params(m.tps, fld),
|
attrs: /* FIXME (#2543) */ copy m.attrs,
|
||||||
self_ty: m.self_ty,
|
tps: fold_ty_params(m.tps, fld),
|
||||||
purity: m.purity,
|
self_ty: m.self_ty,
|
||||||
decl: fold_fn_decl(m.decl, fld),
|
purity: m.purity,
|
||||||
body: fld.fold_block(m.body),
|
decl: fold_fn_decl(m.decl, fld),
|
||||||
id: fld.new_id(m.id),
|
body: fld.fold_block(m.body),
|
||||||
span: fld.new_span(m.span),
|
id: fld.new_id(m.id),
|
||||||
self_id: fld.new_id(m.self_id),
|
span: fld.new_span(m.span),
|
||||||
vis: m.vis};
|
self_id: fld.new_id(m.self_id),
|
||||||
|
vis: m.vis,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -577,20 +586,24 @@ fn noop_fold_ty(t: ty_, fld: ast_fold) -> ty_ {
|
||||||
|
|
||||||
// ...nor do modules
|
// ...nor do modules
|
||||||
fn noop_fold_mod(m: _mod, fld: ast_fold) -> _mod {
|
fn noop_fold_mod(m: _mod, fld: ast_fold) -> _mod {
|
||||||
return {view_items: vec::map(m.view_items, |x| fld.fold_view_item(*x)),
|
ast::_mod {
|
||||||
items: vec::filter_map(m.items, |x| fld.fold_item(*x))};
|
view_items: vec::map(m.view_items, |x| fld.fold_view_item(*x)),
|
||||||
|
items: vec::filter_map(m.items, |x| fld.fold_item(*x)),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn noop_fold_foreign_mod(nm: foreign_mod, fld: ast_fold) -> foreign_mod {
|
fn noop_fold_foreign_mod(nm: foreign_mod, fld: ast_fold) -> foreign_mod {
|
||||||
return {sort: nm.sort,
|
ast::foreign_mod {
|
||||||
abi: nm.abi,
|
sort: nm.sort,
|
||||||
view_items: vec::map(nm.view_items, |x| fld.fold_view_item(*x)),
|
abi: nm.abi,
|
||||||
items: vec::map(nm.items, |x| fld.fold_foreign_item(*x))}
|
view_items: vec::map(nm.view_items, |x| fld.fold_view_item(*x)),
|
||||||
|
items: vec::map(nm.items, |x| fld.fold_foreign_item(*x)),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn noop_fold_variant(v: variant_, fld: ast_fold) -> variant_ {
|
fn noop_fold_variant(v: variant_, fld: ast_fold) -> variant_ {
|
||||||
fn fold_variant_arg_(va: variant_arg, fld: ast_fold) -> variant_arg {
|
fn fold_variant_arg_(va: variant_arg, fld: ast_fold) -> variant_arg {
|
||||||
return {ty: fld.fold_ty(va.ty), id: fld.new_id(va.id)};
|
ast::variant_arg { ty: fld.fold_ty(va.ty), id: fld.new_id(va.id) }
|
||||||
}
|
}
|
||||||
let fold_variant_arg = |x| fold_variant_arg_(x, fld);
|
let fold_variant_arg = |x| fold_variant_arg_(x, fld);
|
||||||
|
|
||||||
|
@ -621,8 +634,12 @@ fn noop_fold_variant(v: variant_, fld: ast_fold) -> variant_ {
|
||||||
|x| fld.fold_variant(*x));
|
|x| fld.fold_variant(*x));
|
||||||
let common = option::map(&(*enum_definition).common,
|
let common = option::map(&(*enum_definition).common,
|
||||||
|x| fold_struct_def(*x, fld));
|
|x| fold_struct_def(*x, fld));
|
||||||
kind = enum_variant_kind(ast::enum_def({ variants: variants,
|
kind = enum_variant_kind(
|
||||||
common: common }));
|
ast::enum_def(ast::enum_def_ {
|
||||||
|
variants: variants,
|
||||||
|
common: common
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -633,12 +650,14 @@ fn noop_fold_variant(v: variant_, fld: ast_fold) -> variant_ {
|
||||||
Some(e) => Some(fld.fold_expr(e)),
|
Some(e) => Some(fld.fold_expr(e)),
|
||||||
None => None
|
None => None
|
||||||
};
|
};
|
||||||
return {name: /* FIXME (#2543) */ copy v.name,
|
ast::variant_ {
|
||||||
attrs: attrs,
|
name: /* FIXME (#2543) */ copy v.name,
|
||||||
kind: kind,
|
attrs: attrs,
|
||||||
id: fld.new_id(v.id),
|
kind: kind,
|
||||||
disr_expr: de,
|
id: fld.new_id(v.id),
|
||||||
vis: v.vis};
|
disr_expr: de,
|
||||||
|
vis: v.vis,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn noop_fold_ident(&&i: ident, _fld: ast_fold) -> ident {
|
fn noop_fold_ident(&&i: ident, _fld: ast_fold) -> ident {
|
||||||
|
|
|
@ -383,8 +383,7 @@ impl Parser {
|
||||||
p.parse_arg_general(false)
|
p.parse_arg_general(false)
|
||||||
};
|
};
|
||||||
let (ret_style, ret_ty) = self.parse_ret_ty();
|
let (ret_style, ret_ty) = self.parse_ret_ty();
|
||||||
return {inputs: inputs, output: ret_ty,
|
ast::fn_decl { inputs: inputs, output: ret_ty, cf: ret_style }
|
||||||
cf: ret_style};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_trait_methods() -> ~[trait_method] {
|
fn parse_trait_methods() -> ~[trait_method] {
|
||||||
|
@ -437,17 +436,19 @@ impl Parser {
|
||||||
let (inner_attrs, body) =
|
let (inner_attrs, body) =
|
||||||
p.parse_inner_attrs_and_block(true);
|
p.parse_inner_attrs_and_block(true);
|
||||||
let attrs = vec::append(attrs, inner_attrs);
|
let attrs = vec::append(attrs, inner_attrs);
|
||||||
provided(@{ident: ident,
|
provided(@ast::method {
|
||||||
attrs: attrs,
|
ident: ident,
|
||||||
tps: tps,
|
attrs: attrs,
|
||||||
self_ty: self_ty,
|
tps: tps,
|
||||||
purity: pur,
|
self_ty: self_ty,
|
||||||
decl: d,
|
purity: pur,
|
||||||
body: body,
|
decl: d,
|
||||||
id: p.get_id(),
|
body: body,
|
||||||
span: mk_sp(lo, hi),
|
id: p.get_id(),
|
||||||
self_id: p.get_id(),
|
span: mk_sp(lo, hi),
|
||||||
vis: vis})
|
self_id: p.get_id(),
|
||||||
|
vis: vis,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => { p.fatal(~"expected `;` or `}` but found `" +
|
_ => { p.fatal(~"expected `;` or `}` but found `" +
|
||||||
|
@ -516,7 +517,7 @@ impl Parser {
|
||||||
None => re_anon
|
None => re_anon
|
||||||
};
|
};
|
||||||
|
|
||||||
@{id: self.get_id(), node: r}
|
@ast::region { id: self.get_id(), node: r }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parses something like "&x"
|
// Parses something like "&x"
|
||||||
|
@ -729,7 +730,7 @@ impl Parser {
|
||||||
|
|
||||||
let t = self.parse_ty(false);
|
let t = self.parse_ty(false);
|
||||||
|
|
||||||
{mode: m, ty: t, pat: pat, id: self.get_id()}
|
ast::arg { mode: m, ty: t, pat: pat, id: self.get_id() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_arg() -> arg_or_capture_item {
|
fn parse_arg() -> arg_or_capture_item {
|
||||||
|
@ -753,7 +754,12 @@ impl Parser {
|
||||||
span: mk_sp(p.span.lo, p.span.hi),
|
span: mk_sp(p.span.lo, p.span.hi),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
either::Left({mode: m, ty: t, pat: pat, id: p.get_id()})
|
either::Left(ast::arg {
|
||||||
|
mode: m,
|
||||||
|
ty: t,
|
||||||
|
pat: pat,
|
||||||
|
id: p.get_id()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1580,8 +1586,8 @@ impl Parser {
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
// No argument list - `do foo {`
|
// No argument list - `do foo {`
|
||||||
({
|
(
|
||||||
{
|
ast::fn_decl {
|
||||||
inputs: ~[],
|
inputs: ~[],
|
||||||
output: @Ty {
|
output: @Ty {
|
||||||
id: self.get_id(),
|
id: self.get_id(),
|
||||||
|
@ -1589,9 +1595,9 @@ impl Parser {
|
||||||
span: self.span
|
span: self.span
|
||||||
},
|
},
|
||||||
cf: return_val
|
cf: return_val
|
||||||
}
|
},
|
||||||
},
|
@~[]
|
||||||
@~[])
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -2549,9 +2555,14 @@ impl Parser {
|
||||||
let capture_clause = @either::rights(args_or_capture_items);
|
let capture_clause = @either::rights(args_or_capture_items);
|
||||||
|
|
||||||
let (ret_style, ret_ty) = self.parse_ret_ty();
|
let (ret_style, ret_ty) = self.parse_ret_ty();
|
||||||
return ({inputs: inputs,
|
(
|
||||||
output: ret_ty,
|
ast::fn_decl {
|
||||||
cf: ret_style}, capture_clause);
|
inputs: inputs,
|
||||||
|
output: ret_ty,
|
||||||
|
cf: ret_style,
|
||||||
|
},
|
||||||
|
capture_clause
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_self_ident() -> bool {
|
fn is_self_ident() -> bool {
|
||||||
|
@ -2651,7 +2662,7 @@ impl Parser {
|
||||||
let capture_clause = @either::rights(args_or_capture_items);
|
let capture_clause = @either::rights(args_or_capture_items);
|
||||||
let (ret_style, ret_ty) = self.parse_ret_ty();
|
let (ret_style, ret_ty) = self.parse_ret_ty();
|
||||||
|
|
||||||
let fn_decl = {
|
let fn_decl = ast::fn_decl {
|
||||||
inputs: inputs,
|
inputs: inputs,
|
||||||
output: ret_ty,
|
output: ret_ty,
|
||||||
cf: ret_style
|
cf: ret_style
|
||||||
|
@ -2676,10 +2687,15 @@ impl Parser {
|
||||||
} else {
|
} else {
|
||||||
@Ty { id: self.get_id(), node: ty_infer, span: self.span }
|
@Ty { id: self.get_id(), node: ty_infer, span: self.span }
|
||||||
};
|
};
|
||||||
return ({inputs: either::lefts(inputs_captures),
|
|
||||||
output: output,
|
(
|
||||||
cf: return_val},
|
ast::fn_decl {
|
||||||
@either::rights(inputs_captures));
|
inputs: either::lefts(inputs_captures),
|
||||||
|
output: output,
|
||||||
|
cf: return_val,
|
||||||
|
},
|
||||||
|
@either::rights(inputs_captures)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_fn_header() -> {ident: ident, tps: ~[ty_param]} {
|
fn parse_fn_header() -> {ident: ident, tps: ~[ty_param]} {
|
||||||
|
@ -2729,10 +2745,19 @@ impl Parser {
|
||||||
|
|
||||||
let (inner_attrs, body) = self.parse_inner_attrs_and_block(true);
|
let (inner_attrs, body) = self.parse_inner_attrs_and_block(true);
|
||||||
let attrs = vec::append(attrs, inner_attrs);
|
let attrs = vec::append(attrs, inner_attrs);
|
||||||
@{ident: ident, attrs: attrs,
|
@ast::method {
|
||||||
tps: tps, self_ty: self_ty, purity: pur, decl: decl,
|
ident: ident,
|
||||||
body: body, id: self.get_id(), span: mk_sp(lo, body.span.hi),
|
attrs: attrs,
|
||||||
self_id: self.get_id(), vis: visa}
|
tps: tps,
|
||||||
|
self_ty: self_ty,
|
||||||
|
purity: pur,
|
||||||
|
decl: decl,
|
||||||
|
body: body,
|
||||||
|
id: self.get_id(),
|
||||||
|
span: mk_sp(lo, body.span.hi),
|
||||||
|
self_id: self.get_id(),
|
||||||
|
vis: visa,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_item_trait() -> item_info {
|
fn parse_item_trait() -> item_info {
|
||||||
|
@ -2832,8 +2857,10 @@ impl Parser {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_trait_ref() -> @trait_ref {
|
fn parse_trait_ref() -> @trait_ref {
|
||||||
@{path: self.parse_path_with_tps(false),
|
@ast::trait_ref {
|
||||||
ref_id: self.get_id()}
|
path: self.parse_path_with_tps(false),
|
||||||
|
ref_id: self.get_id(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_trait_ref_list(ket: token::Token) -> ~[@trait_ref] {
|
fn parse_trait_ref_list(ket: token::Token) -> ~[@trait_ref] {
|
||||||
|
@ -3065,7 +3092,7 @@ impl Parser {
|
||||||
self.fatal(~"expected item");
|
self.fatal(~"expected item");
|
||||||
}
|
}
|
||||||
|
|
||||||
return {view_items: view_items, items: items};
|
ast::_mod { view_items: view_items, items: items }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_item_const() -> item_info {
|
fn parse_item_const() -> item_info {
|
||||||
|
@ -3117,7 +3144,7 @@ impl Parser {
|
||||||
(item_mod(m), item_mod(n)) => (m, n),
|
(item_mod(m), item_mod(n)) => (m, n),
|
||||||
_ => self.bug(~"parsed mod item should be mod")
|
_ => self.bug(~"parsed mod item should be mod")
|
||||||
};
|
};
|
||||||
let merged_mod = {
|
let merged_mod = ast::_mod {
|
||||||
view_items: main_mod.view_items + new_mod.view_items,
|
view_items: main_mod.view_items + new_mod.view_items,
|
||||||
items: main_mod.items + new_mod.items
|
items: main_mod.items + new_mod.items
|
||||||
};
|
};
|
||||||
|
@ -3272,12 +3299,12 @@ impl Parser {
|
||||||
initial_attrs = ~[];
|
initial_attrs = ~[];
|
||||||
items.push(self.parse_foreign_item(attrs));
|
items.push(self.parse_foreign_item(attrs));
|
||||||
}
|
}
|
||||||
return {
|
ast::foreign_mod {
|
||||||
sort: sort,
|
sort: sort,
|
||||||
abi: move abi,
|
abi: move abi,
|
||||||
view_items: view_items,
|
view_items: view_items,
|
||||||
items: items
|
items: items
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_item_foreign_mod(lo: BytePos,
|
fn parse_item_foreign_mod(lo: BytePos,
|
||||||
|
@ -3473,7 +3500,10 @@ impl Parser {
|
||||||
seq_sep_trailing_disallowed(token::COMMA),
|
seq_sep_trailing_disallowed(token::COMMA),
|
||||||
|p| p.parse_ty(false));
|
|p| p.parse_ty(false));
|
||||||
for arg_tys.each |ty| {
|
for arg_tys.each |ty| {
|
||||||
args.push({ty: *ty, id: self.get_id()});
|
args.push(ast::variant_arg {
|
||||||
|
ty: *ty,
|
||||||
|
id: self.get_id(),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
kind = tuple_variant_kind(args);
|
kind = tuple_variant_kind(args);
|
||||||
} else if self.eat(token::EQ) {
|
} else if self.eat(token::EQ) {
|
||||||
|
@ -3486,9 +3516,14 @@ impl Parser {
|
||||||
needs_comma = true;
|
needs_comma = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
let vr = {name: ident, attrs: variant_attrs,
|
let vr = ast::variant_ {
|
||||||
kind: kind, id: self.get_id(),
|
name: ident,
|
||||||
disr_expr: disr_expr, vis: vis};
|
attrs: variant_attrs,
|
||||||
|
kind: kind,
|
||||||
|
id: self.get_id(),
|
||||||
|
disr_expr: disr_expr,
|
||||||
|
vis: vis,
|
||||||
|
};
|
||||||
variants.push(spanned(vlo, self.last_span.hi, vr));
|
variants.push(spanned(vlo, self.last_span.hi, vr));
|
||||||
|
|
||||||
if needs_comma && !self.eat(token::COMMA) { break; }
|
if needs_comma && !self.eat(token::COMMA) { break; }
|
||||||
|
@ -3499,7 +3534,7 @@ impl Parser {
|
||||||
enum");
|
enum");
|
||||||
}
|
}
|
||||||
|
|
||||||
return enum_def({ variants: variants, common: common_fields });
|
enum_def(ast::enum_def_ { variants: variants, common: common_fields })
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_item_enum() -> item_info {
|
fn parse_item_enum() -> item_info {
|
||||||
|
@ -3511,18 +3546,26 @@ impl Parser {
|
||||||
self.bump();
|
self.bump();
|
||||||
let ty = self.parse_ty(false);
|
let ty = self.parse_ty(false);
|
||||||
self.expect(token::SEMI);
|
self.expect(token::SEMI);
|
||||||
let variant =
|
let variant = spanned(ty.span.lo, ty.span.hi, ast::variant_ {
|
||||||
spanned(ty.span.lo, ty.span.hi,
|
name: id,
|
||||||
{name: id,
|
attrs: ~[],
|
||||||
attrs: ~[],
|
kind: tuple_variant_kind(
|
||||||
kind: tuple_variant_kind
|
~[ast::variant_arg {ty: ty, id: self.get_id()}]
|
||||||
(~[{ty: ty, id: self.get_id()}]),
|
),
|
||||||
id: self.get_id(),
|
id: self.get_id(),
|
||||||
disr_expr: None,
|
disr_expr: None,
|
||||||
vis: public});
|
vis: public,
|
||||||
return (id, item_enum(enum_def({ variants: ~[variant],
|
});
|
||||||
common: None }),
|
|
||||||
ty_params), None);
|
return (
|
||||||
|
id,
|
||||||
|
item_enum(
|
||||||
|
enum_def(
|
||||||
|
ast::enum_def_ { variants: ~[variant], common: None }
|
||||||
|
),
|
||||||
|
ty_params),
|
||||||
|
None
|
||||||
|
);
|
||||||
}
|
}
|
||||||
self.expect(token::LBRACE);
|
self.expect(token::LBRACE);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue