Consolidate obj_field_from_anon_obj_field().

This commit is contained in:
Lindsey Kuper 2011-07-21 15:10:12 -07:00
parent 55acc737a8
commit 8ebd292253
3 changed files with 8 additions and 10 deletions

View file

@ -6252,12 +6252,8 @@ fn trans_anon_obj(@block_ctxt bcx, &span sp, &ast::anon_obj anon_obj,
// create_vtbl() wants an ast::_obj and all we have is an ast::anon_obj,
// so we need to roll our own.
fn anon_obj_field_to_obj_field(&ast::anon_obj_field f)
-> ast::obj_field {
ret rec(mut=f.mut, ty=f.ty, ident=f.ident, id=f.id);
}
let ast::_obj wrapper_obj = rec(
fields = std::ivec::map(anon_obj_field_to_obj_field,
fields = std::ivec::map(ast::obj_field_from_anon_obj_field,
additional_fields),
methods = anon_obj.methods,
dtor = none[@ast::method]);

View file

@ -2481,12 +2481,9 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
}
}
fn ao_field_to_o_field(&ast::anon_obj_field f)
-> ast::obj_field {
ret rec(mut=f.mut, ty=f.ty, ident=f.ident, id=f.id);
}
fcx.ccx.obj_infos +=
~[anon_obj(ivec::map(ao_field_to_o_field, fields),
~[anon_obj(ivec::map(ast::obj_field_from_anon_obj_field,
fields),
with_obj_sty)];
methods += with_obj_methods;

View file

@ -664,6 +664,11 @@ fn block_from_expr(@expr e) -> block {
ret rec(node=blk_, span=e.span);
}
fn obj_field_from_anon_obj_field(&anon_obj_field f) -> obj_field {
ret rec(mut=f.mut, ty=f.ty, ident=f.ident, id=f.id);
}
// This is a convenience function to transfor ternary expressions to if
// expressions so that they can be treated the same
fn ternary_to_if(&@expr e) -> @ast::expr {