Make empty structs debug-printable
This commit is contained in:
parent
1b4f3fad1e
commit
ea53c48ca2
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user