Make empty structs debug-printable

This commit is contained in:
Jed Davis 2013-01-08 00:24:25 -08:00 committed by Tim Chevalier
parent 1b4f3fad1e
commit ea53c48ca2

View File

@ -1330,9 +1330,10 @@ fn type_to_str_inner(names: type_names, +outer0: ~[TypeRef], ty: TypeRef) ->
let mut s: ~str = ~"{"; let mut s: ~str = ~"{";
let n_elts = llvm::LLVMCountStructElementTypes(ty) as uint; let n_elts = llvm::LLVMCountStructElementTypes(ty) as uint;
let mut elts = vec::from_elem(n_elts, 0 as TypeRef); let mut elts = vec::from_elem(n_elts, 0 as TypeRef);
llvm::LLVMGetStructElementTypes(ty, if elts.len() > 0 {
ptr::to_mut_unsafe_ptr( llvm::LLVMGetStructElementTypes(
&mut elts[0])); ty, ptr::to_mut_unsafe_ptr(&mut elts[0]));
}
s += tys_str(names, outer, elts); s += tys_str(names, outer, elts);
s += ~"}"; s += ~"}";
return s; return s;
@ -1398,8 +1399,10 @@ fn struct_element_types(struct_ty: TypeRef) -> ~[TypeRef] {
let mut buf: ~[TypeRef] = let mut buf: ~[TypeRef] =
vec::from_elem(count as uint, vec::from_elem(count as uint,
cast::transmute::<uint,TypeRef>(0)); cast::transmute::<uint,TypeRef>(0));
llvm::LLVMGetStructElementTypes(struct_ty, if buf.len() > 0 {
ptr::to_mut_unsafe_ptr(&mut buf[0])); llvm::LLVMGetStructElementTypes(
struct_ty, ptr::to_mut_unsafe_ptr(&mut buf[0]));
}
return move buf; return move buf;
} }
} }