Skip to content

Commit

Permalink
Auto merge of #1014 - pepyakin:generate-base-names, r=fitzgen
Browse files Browse the repository at this point in the history
Generate base names upon construction

As per #1012 (comment)
r? @fitzgen
  • Loading branch information
bors-servo authored Sep 22, 2017
2 parents 30d6e04 + 24c2037 commit becdc79
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/codegen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1559,7 +1559,7 @@ impl CodeGenerator for CompInfo {
struct_layout.saw_vtable();
}

for (i, base) in self.base_members().iter().enumerate() {
for base in self.base_members() {
// Virtual bases are already taken into account by the vtable
// pointer.
//
Expand All @@ -1577,11 +1577,7 @@ impl CodeGenerator for CompInfo {
}

let inner = base.ty.to_rust_ty_or_opaque(ctx, &());
let field_name = ctx.rust_ident(if i == 0 {
"_base".into()
} else {
format!("_base_{}", i)
});
let field_name = ctx.rust_ident(&base.field_name);

struct_layout.saw_base(base_ty);

Expand Down
7 changes: 7 additions & 0 deletions src/ir/comp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,8 @@ pub struct Base {
pub ty: ItemId,
/// The kind of inheritance we're doing.
pub kind: BaseKind,
/// Name of the field in which this base should be stored.
pub field_name: String,
}

impl Base {
Expand Down Expand Up @@ -1155,11 +1157,16 @@ impl CompInfo {
BaseKind::Normal
};

let field_name = match ci.base_members.len() {
0 => "_base".into(),
n => format!("_base_{}", n),
};
let type_id =
Item::from_ty_or_ref(cur.cur_type(), cur, None, ctx);
ci.base_members.push(Base {
ty: type_id,
kind: kind,
field_name: field_name,
});
}
CXCursor_Constructor |
Expand Down

0 comments on commit becdc79

Please sign in to comment.