提交 8ebd2922 编写于 作者: L Lindsey Kuper

Consolidate obj_field_from_anon_obj_field().

上级 55acc737
......@@ -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]);
......
......@@ -2481,12 +2481,9 @@ fn get_anon_obj_method_types(@fn_ctxt fcx,
}
}
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;
......
......@@ -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 {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册