Merge pull request #4703 from sanxiyn/remove-tps
Remove `tps` from `trans_enum_def` and `trans_struct_def`
This commit is contained in:
commit
9673005afe
1 changed files with 22 additions and 25 deletions
|
@ -1986,7 +1986,7 @@ pub fn trans_struct_dtor(ccx: @crate_ctxt,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn trans_enum_def(ccx: @crate_ctxt, enum_definition: ast::enum_def,
|
pub fn trans_enum_def(ccx: @crate_ctxt, enum_definition: ast::enum_def,
|
||||||
id: ast::node_id, tps: ~[ast::ty_param], degen: bool,
|
id: ast::node_id, degen: bool,
|
||||||
path: @ast_map::path, vi: @~[ty::VariantInfo],
|
path: @ast_map::path, vi: @~[ty::VariantInfo],
|
||||||
i: &mut uint) {
|
i: &mut uint) {
|
||||||
for vec::each(enum_definition.variants) |variant| {
|
for vec::each(enum_definition.variants) |variant| {
|
||||||
|
@ -2003,14 +2003,13 @@ pub fn trans_enum_def(ccx: @crate_ctxt, enum_definition: ast::enum_def,
|
||||||
// Nothing to do.
|
// Nothing to do.
|
||||||
}
|
}
|
||||||
ast::struct_variant_kind(struct_def) => {
|
ast::struct_variant_kind(struct_def) => {
|
||||||
trans_struct_def(ccx, struct_def, /*bad*/copy tps, path,
|
trans_struct_def(ccx, struct_def, path,
|
||||||
variant.node.id);
|
variant.node.id);
|
||||||
}
|
}
|
||||||
ast::enum_variant_kind(ref enum_definition) => {
|
ast::enum_variant_kind(ref enum_definition) => {
|
||||||
trans_enum_def(ccx,
|
trans_enum_def(ccx,
|
||||||
*enum_definition,
|
*enum_definition,
|
||||||
id,
|
id,
|
||||||
/*bad*/copy tps,
|
|
||||||
degen,
|
degen,
|
||||||
path,
|
path,
|
||||||
vi,
|
vi,
|
||||||
|
@ -2062,11 +2061,11 @@ pub fn trans_item(ccx: @crate_ctxt, item: ast::item) {
|
||||||
trans_mod(ccx, m);
|
trans_mod(ccx, m);
|
||||||
}
|
}
|
||||||
ast::item_enum(ref enum_definition, ref tps) => {
|
ast::item_enum(ref enum_definition, ref tps) => {
|
||||||
if tps.len() == 0u {
|
if tps.is_empty() {
|
||||||
let degen = (*enum_definition).variants.len() == 1u;
|
let degen = (*enum_definition).variants.len() == 1u;
|
||||||
let vi = ty::enum_variants(ccx.tcx, local_def(item.id));
|
let vi = ty::enum_variants(ccx.tcx, local_def(item.id));
|
||||||
let mut i = 0;
|
let mut i = 0;
|
||||||
trans_enum_def(ccx, (*enum_definition), item.id, /*bad*/copy *tps,
|
trans_enum_def(ccx, (*enum_definition), item.id,
|
||||||
degen, path, vi, &mut i);
|
degen, path, vi, &mut i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2080,18 +2079,17 @@ pub fn trans_item(ccx: @crate_ctxt, item: ast::item) {
|
||||||
foreign::trans_foreign_mod(ccx, foreign_mod, abi);
|
foreign::trans_foreign_mod(ccx, foreign_mod, abi);
|
||||||
}
|
}
|
||||||
ast::item_struct(struct_def, tps) => {
|
ast::item_struct(struct_def, tps) => {
|
||||||
trans_struct_def(ccx, struct_def, tps, path, item.id);
|
if tps.is_empty() {
|
||||||
|
trans_struct_def(ccx, struct_def, path, item.id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_ => {/* fall through */ }
|
_ => {/* fall through */ }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn trans_struct_def(ccx: @crate_ctxt, struct_def: @ast::struct_def,
|
pub fn trans_struct_def(ccx: @crate_ctxt, struct_def: @ast::struct_def,
|
||||||
tps: ~[ast::ty_param], path: @ast_map::path,
|
path: @ast_map::path,
|
||||||
id: ast::node_id) {
|
id: ast::node_id) {
|
||||||
// If there are type parameters, the destructor and constructor will be
|
|
||||||
// monomorphized, so we don't translate them here.
|
|
||||||
if tps.len() == 0u {
|
|
||||||
// Translate the destructor.
|
// Translate the destructor.
|
||||||
do option::iter(&struct_def.dtor) |dtor| {
|
do option::iter(&struct_def.dtor) |dtor| {
|
||||||
trans_struct_dtor(ccx, /*bad*/copy *path, dtor.node.body,
|
trans_struct_dtor(ccx, /*bad*/copy *path, dtor.node.body,
|
||||||
|
@ -2110,7 +2108,6 @@ pub fn trans_struct_def(ccx: @crate_ctxt, struct_def: @ast::struct_def,
|
||||||
Some(_) | None => {}
|
Some(_) | None => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Translate a module. Doing this amounts to translating the items in the
|
// Translate a module. Doing this amounts to translating the items in the
|
||||||
// module; there ends up being no artifact (aside from linkage names) of
|
// module; there ends up being no artifact (aside from linkage names) of
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue