convert ast::foreign_item to a struct
This commit is contained in:
parent
e1f1a1204a
commit
5c0d674a45
5 changed files with 42 additions and 36 deletions
|
|
@ -107,7 +107,8 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint)
|
|||
ast_map::node_variant(_, _, _) => {
|
||||
for uint::range(0u, n_tps) |n| { cx.uses[n] |= use_repr;}
|
||||
}
|
||||
ast_map::node_foreign_item(i@@{node: foreign_item_fn(*), _},
|
||||
ast_map::node_foreign_item(i@@foreign_item { node: foreign_item_fn(*),
|
||||
_ },
|
||||
abi, _) => {
|
||||
if abi == foreign_abi_rust_intrinsic {
|
||||
let flags = match cx.ccx.sess.str_of(i.ident) {
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ fn get_fn_sig(srv: astsrv::Srv, fn_id: doc::AstId) -> Option<~str> {
|
|||
ident: ident,
|
||||
node: ast::item_fn(decl, _, tys, _), _
|
||||
}, _) |
|
||||
ast_map::node_foreign_item(@{
|
||||
ast_map::node_foreign_item(@ast::foreign_item {
|
||||
ident: ident,
|
||||
node: ast::foreign_item_fn(decl, _, tys), _
|
||||
}, _, _) => {
|
||||
|
|
|
|||
|
|
@ -1574,13 +1574,14 @@ type struct_dtor_ = {id: node_id,
|
|||
|
||||
#[auto_encode]
|
||||
#[auto_decode]
|
||||
type foreign_item =
|
||||
{ident: ident,
|
||||
attrs: ~[attribute],
|
||||
node: foreign_item_,
|
||||
id: node_id,
|
||||
span: span,
|
||||
vis: visibility};
|
||||
struct foreign_item {
|
||||
ident: ident,
|
||||
attrs: ~[attribute],
|
||||
node: foreign_item_,
|
||||
id: node_id,
|
||||
span: span,
|
||||
vis: visibility,
|
||||
}
|
||||
|
||||
#[auto_encode]
|
||||
#[auto_decode]
|
||||
|
|
|
|||
|
|
@ -178,25 +178,29 @@ fn noop_fold_foreign_item(&&ni: @foreign_item, fld: ast_fold)
|
|||
let fold_arg = |x| fold_arg_(x, fld);
|
||||
let fold_attribute = |x| fold_attribute_(x, fld);
|
||||
|
||||
return @{ident: fld.fold_ident(ni.ident),
|
||||
attrs: vec::map(ni.attrs, |x| fold_attribute(*x)),
|
||||
node:
|
||||
match ni.node {
|
||||
@ast::foreign_item {
|
||||
ident: fld.fold_ident(ni.ident),
|
||||
attrs: vec::map(ni.attrs, |x| fold_attribute(*x)),
|
||||
node:
|
||||
match ni.node {
|
||||
foreign_item_fn(fdec, purity, typms) => {
|
||||
foreign_item_fn(
|
||||
{inputs: vec::map(fdec.inputs, |a| fold_arg(*a)),
|
||||
output: fld.fold_ty(fdec.output),
|
||||
cf: fdec.cf},
|
||||
purity,
|
||||
fold_ty_params(typms, fld))
|
||||
foreign_item_fn(
|
||||
{
|
||||
inputs: fdec.inputs.map(|a| fold_arg(*a)),
|
||||
output: fld.fold_ty(fdec.output),
|
||||
cf: fdec.cf,
|
||||
},
|
||||
purity,
|
||||
fold_ty_params(typms, fld))
|
||||
}
|
||||
foreign_item_const(t) => {
|
||||
foreign_item_const(fld.fold_ty(t))
|
||||
foreign_item_const(fld.fold_ty(t))
|
||||
}
|
||||
},
|
||||
id: fld.new_id(ni.id),
|
||||
span: fld.new_span(ni.span),
|
||||
vis: ni.vis};
|
||||
},
|
||||
id: fld.new_id(ni.id),
|
||||
span: fld.new_span(ni.span),
|
||||
vis: ni.vis,
|
||||
}
|
||||
}
|
||||
|
||||
fn noop_fold_item(&&i: @item, fld: ast_fold) -> Option<@item> {
|
||||
|
|
|
|||
|
|
@ -3123,12 +3123,12 @@ impl Parser {
|
|||
let (decl, _) = self.parse_fn_decl(|p| p.parse_arg());
|
||||
let mut hi = self.span.hi;
|
||||
self.expect(token::SEMI);
|
||||
return @{ident: t.ident,
|
||||
attrs: attrs,
|
||||
node: foreign_item_fn(decl, purity, t.tps),
|
||||
id: self.get_id(),
|
||||
span: mk_sp(lo, hi),
|
||||
vis: vis};
|
||||
@ast::foreign_item { ident: t.ident,
|
||||
attrs: attrs,
|
||||
node: foreign_item_fn(decl, purity, t.tps),
|
||||
id: self.get_id(),
|
||||
span: mk_sp(lo, hi),
|
||||
vis: vis }
|
||||
}
|
||||
|
||||
fn parse_item_foreign_const(vis: ast::visibility,
|
||||
|
|
@ -3140,12 +3140,12 @@ impl Parser {
|
|||
let ty = self.parse_ty(false);
|
||||
let hi = self.span.hi;
|
||||
self.expect(token::SEMI);
|
||||
return @{ident: ident,
|
||||
attrs: attrs,
|
||||
node: foreign_item_const(move ty),
|
||||
id: self.get_id(),
|
||||
span: mk_sp(lo, hi),
|
||||
vis: vis};
|
||||
@ast::foreign_item { ident: ident,
|
||||
attrs: attrs,
|
||||
node: foreign_item_const(ty),
|
||||
id: self.get_id(),
|
||||
span: mk_sp(lo, hi),
|
||||
vis: vis }
|
||||
}
|
||||
|
||||
fn parse_fn_purity() -> purity {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue