@@ -2149,12 +2149,17 @@ impl TypeNames {
2149
2149
self . named_types . find_equiv ( & s) . map_consume ( |x| Type :: from_ref ( * x) )
2150
2150
}
2151
2151
2152
- pub fn type_to_str ( & self , ty : Type ) -> ~str {
2152
+ // We have a depth count, because we seem to make infinite types.
2153
+ pub fn type_to_str_depth ( & self , ty : Type , depth : int ) -> ~str {
2153
2154
match self . find_name ( & ty) {
2154
2155
option:: Some ( name) => return name. to_owned ( ) ,
2155
2156
None => ( )
2156
2157
}
2157
2158
2159
+ if depth == 0 {
2160
+ return ~"###";
2161
+ }
2162
+
2158
2163
unsafe {
2159
2164
let kind = ty. kind ( ) ;
2160
2165
@@ -2176,31 +2181,36 @@ impl TypeNames {
2176
2181
Function => {
2177
2182
let out_ty = ty. return_type ( ) ;
2178
2183
let args = ty. func_params ( ) ;
2179
- let args = args. map ( |& ty| self . type_to_str ( ty) ) . connect ( ", " ) ;
2180
- let out_ty = self . type_to_str ( out_ty) ;
2184
+ let args =
2185
+ args. map ( |& ty| self . type_to_str_depth ( ty, depth-1 ) ) . connect ( ", " ) ;
2186
+ let out_ty = self . type_to_str_depth ( out_ty, depth-1 ) ;
2181
2187
fmt ! ( "fn(%s) -> %s" , args, out_ty)
2182
2188
}
2183
2189
Struct => {
2184
2190
let tys = ty. field_types ( ) ;
2185
- let tys = tys. map ( |& ty| self . type_to_str ( ty) ) . connect ( ", " ) ;
2191
+ let tys = tys. map ( |& ty| self . type_to_str_depth ( ty, depth- 1 ) ) . connect ( ", " ) ;
2186
2192
fmt ! ( "{%s}" , tys)
2187
2193
}
2188
2194
Array => {
2189
2195
let el_ty = ty. element_type ( ) ;
2190
- let el_ty = self . type_to_str ( el_ty) ;
2196
+ let el_ty = self . type_to_str_depth ( el_ty, depth- 1 ) ;
2191
2197
let len = ty. array_length ( ) ;
2192
2198
fmt ! ( "[%s x %u]" , el_ty, len)
2193
2199
}
2194
2200
Pointer => {
2195
2201
let el_ty = ty. element_type ( ) ;
2196
- let el_ty = self . type_to_str ( el_ty) ;
2202
+ let el_ty = self . type_to_str_depth ( el_ty, depth- 1 ) ;
2197
2203
fmt ! ( "*%s" , el_ty)
2198
2204
}
2199
2205
_ => fail ! ( "Unknown Type Kind (%u)" , kind as uint)
2200
2206
}
2201
2207
}
2202
2208
}
2203
2209
2210
+ pub fn type_to_str ( & self , ty : Type ) -> ~str {
2211
+ self . type_to_str_depth ( ty, 30 )
2212
+ }
2213
+
2204
2214
pub fn val_to_str ( & self , val : ValueRef ) -> ~str {
2205
2215
unsafe {
2206
2216
let ty = Type :: from_ref ( llvm:: LLVMTypeOf ( val) ) ;
0 commit comments