Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/type_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,18 @@ impl<'gcc, 'tcx> BaseTypeMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
self.context.new_function_pointer_type(None, return_type, params, false)
}

fn type_struct(&self, fields: &[Type<'gcc>], _packed: bool) -> Type<'gcc> {
fn type_struct(&self, fields: &[Type<'gcc>], packed: bool) -> Type<'gcc> {
let types = fields.to_vec();
if let Some(typ) = self.struct_types.borrow().get(fields) {
return typ.clone();
}
let fields: Vec<_> = fields.iter().enumerate()
.map(|(index, field)| self.context.new_field(None, *field, &format!("field{}_TODO", index)))
.collect();
// TODO(antoyo): use packed.
let typ = self.context.new_struct_type(None, "struct", &fields).as_type();
if packed {
typ.set_packed();
}
self.struct_types.borrow_mut().insert(types, typ);
typ
}
Expand Down Expand Up @@ -209,12 +211,14 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
self.type_array(self.type_from_integer(unit), size / unit_size)
}

pub fn set_struct_body(&self, typ: Struct<'gcc>, fields: &[Type<'gcc>], _packed: bool) {
// TODO(antoyo): use packed.
pub fn set_struct_body(&self, typ: Struct<'gcc>, fields: &[Type<'gcc>], packed: bool) {
let fields: Vec<_> = fields.iter().enumerate()
.map(|(index, field)| self.context.new_field(None, *field, &format!("field_{}", index)))
.collect();
typ.set_fields(None, &fields);
if packed {
typ.as_type().set_packed();
}
}

pub fn type_named_struct(&self, name: &str) -> Struct<'gcc> {
Expand Down