@@ -230,8 +230,8 @@ fn create_block(cx: @block_ctxt) -> @metadata<block_md> {
230
230
let cx = cx;
231
231
while option:: is_none ( cx. block_span ) {
232
232
alt cx. parent {
233
- parent_none { fail "BAD" ; /*break;*/ }
234
233
parent_some ( b) { cx = b; }
234
+ parent_none { fail; }
235
235
}
236
236
}
237
237
let sp = option:: get ( cx. block_span ) ;
@@ -275,7 +275,7 @@ fn size_and_align_of<T>() -> (int, int) {
275
275
( sys:: size_of :: < T > ( ) as int , sys:: align_of :: < T > ( ) as int )
276
276
}
277
277
278
- fn create_basic_type ( cx : @crate_ctxt , t : ty:: t , ty : @ ast:: ty )
278
+ fn create_basic_type ( cx : @crate_ctxt , t : ty:: t , ty : ast:: prim_ty , span : span )
279
279
-> @metadata < tydesc_md > {
280
280
let cache = get_cache ( cx) ;
281
281
let tg = BasicTypeDescriptorTag ;
@@ -285,7 +285,7 @@ fn create_basic_type(cx: @crate_ctxt, t: ty::t, ty: @ast::ty)
285
285
option:: none { }
286
286
}
287
287
288
- let ( name, ( size, align) , encoding) = alt ty. node {
288
+ let ( name, ( size, align) , encoding) = alt ty {
289
289
ast : : ty_bool { ( "bool" , size_and_align_of :: < bool > ( ) , DW_ATE_boolean ) }
290
290
ast:: ty_int ( m) { alt m {
291
291
ast : : ty_char { ( "char" , size_and_align_of :: < char > ( ) , DW_ATE_unsigned ) }
@@ -307,11 +307,10 @@ fn create_basic_type(cx: @crate_ctxt, t: ty::t, ty: @ast::ty)
307
307
ast:: ty_f32 { ( "f32" , size_and_align_of :: < f32 > ( ) , DW_ATE_float ) }
308
308
ast:: ty_f64 { ( "f64" , size_and_align_of :: < f64 > ( ) , DW_ATE_float ) }
309
309
} }
310
- _ { cx. tcx . sess . span_bug ( ty. span ,
311
- "create_basic_type: unhandled type" ) ; }
310
+ _ { fail; }
312
311
} ;
313
312
314
- let fname = filename_from_span ( cx, ty . span ) ;
313
+ let fname = filename_from_span ( cx, span) ;
315
314
let file_node = create_file ( cx, fname) ;
316
315
let cu_node = create_compile_unit ( cx, fname) ;
317
316
let lldata = [ lltag ( tg) ,
@@ -415,7 +414,7 @@ fn create_record(cx: @crate_ctxt, t: ty::t, fields: [ast::ty_field],
415
414
for field in fields {
416
415
let field_t = ty:: get_field ( ccx_tcx ( cx) , t, field. node . ident ) . mt . ty ;
417
416
let ty_md = create_ty ( cx, field_t, field. node . mt . ty ) ;
418
- let ( size, align) = member_size_and_align ( field. node . mt . ty ) ;
417
+ let ( size, align) = member_size_and_align ( cx . tcx , field. node . mt . ty ) ;
419
418
add_member ( scx, field. node . ident ,
420
419
line_from_span ( cx. sess . codemap , field. span ) as int ,
421
420
size as int , align as int , ty_md. node ) ;
@@ -439,8 +438,8 @@ fn create_boxed_type(cx: @crate_ctxt, outer: ty::t, _inner: ty::t,
439
438
//let cu_node = create_compile_unit_metadata(cx, fname);
440
439
let tcx = ccx_tcx ( cx) ;
441
440
let uint_t = ty:: mk_uint ( tcx) ;
442
- let uint_ty = @ { node : ast :: ty_uint ( ast :: ty_u ) , span : span } ;
443
- let refcount_type = create_basic_type ( cx , uint_t , uint_ty ) ;
441
+ let refcount_type = create_basic_type ( cx , uint_t ,
442
+ ast :: ty_uint ( ast :: ty_u ) , span ) ;
444
443
let scx = create_structure ( file_node, ty_to_str ( ccx_tcx ( cx) , outer) , 0 ) ;
445
444
add_member ( scx, "refcnt" , 0 , sys:: size_of :: < uint > ( ) as int ,
446
445
sys:: align_of :: < uint > ( ) as int , refcount_type. node ) ;
@@ -492,14 +491,14 @@ fn create_vec(cx: @crate_ctxt, vec_t: ty::t, elem_t: ty::t,
492
491
let elem_ty_md = create_ty ( cx, elem_t, elem_ty) ;
493
492
let tcx = ccx_tcx ( cx) ;
494
493
let scx = create_structure ( file_node, ty_to_str ( tcx, vec_t) , 0 ) ;
495
- let uint_ty = @ { node : ast :: ty_uint ( ast :: ty_u ) , span : vec_ty_span } ;
496
- let size_t_type = create_basic_type ( cx , ty :: mk_uint ( tcx ) , uint_ty ) ;
494
+ let size_t_type = create_basic_type ( cx , ty :: mk_uint ( tcx ) ,
495
+ ast :: ty_uint ( ast :: ty_u ) , vec_ty_span ) ;
497
496
add_member ( scx, "fill" , 0 , sys:: size_of :: < ctypes:: size_t > ( ) as int ,
498
497
sys:: align_of :: < ctypes:: size_t > ( ) as int , size_t_type. node ) ;
499
498
add_member ( scx, "alloc" , 0 , sys:: size_of :: < ctypes:: size_t > ( ) as int ,
500
499
sys:: align_of :: < ctypes:: size_t > ( ) as int , size_t_type. node ) ;
501
500
let subrange = llmdnode ( [ lltag ( SubrangeTag ) , lli64 ( 0 ) , lli64 ( 0 ) ] ) ;
502
- let ( arr_size, arr_align) = member_size_and_align ( elem_ty) ;
501
+ let ( arr_size, arr_align) = member_size_and_align ( tcx , elem_ty) ;
503
502
let data_ptr = create_composite_type ( ArrayTypeTag , "" , file_node. node , 0 ,
504
503
arr_size, arr_align, 0 ,
505
504
option:: some ( elem_ty_md. node ) ,
@@ -510,36 +509,46 @@ fn create_vec(cx: @crate_ctxt, vec_t: ty::t, elem_t: ty::t,
510
509
ret @{ node : llnode, data : { hash: ty:: type_id ( vec_t) } } ;
511
510
}
512
511
513
- fn member_size_and_align ( ty : @ast:: ty ) -> ( int , int ) {
512
+ fn member_size_and_align ( tcx : ty :: ctxt , ty : @ast:: ty ) -> ( int , int ) {
514
513
alt ty. node {
515
- ast:: ty_bool { size_and_align_of : : <bool >( ) }
516
- ast:: ty_int ( m) { alt m {
517
- ast : : ty_char { size_and_align_of : : <char >( ) }
518
- ast:: ty_i { size_and_align_of : : <int >( ) }
519
- ast:: ty_i8 { size_and_align_of : : <i8 >( ) }
520
- ast:: ty_i16 { size_and_align_of : : <i16 >( ) }
521
- ast:: ty_i32 { size_and_align_of : : <i32 >( ) }
522
- ast:: ty_i64 { size_and_align_of : : <i64 >( ) }
523
- } }
524
- ast:: ty_uint ( m) { alt m {
525
- ast : : ty_u { size_and_align_of : : <uint >( ) }
526
- ast:: ty_u8 { size_and_align_of : : <i8 >( ) }
527
- ast:: ty_u16 { size_and_align_of : : <u16 >( ) }
528
- ast:: ty_u32 { size_and_align_of : : <u32 >( ) }
529
- ast:: ty_u64 { size_and_align_of : : <u64 >( ) }
530
- } }
531
- ast:: ty_float ( m) { alt m {
532
- ast : : ty_f { size_and_align_of : : <float >( ) }
533
- ast:: ty_f32 { size_and_align_of : : <f32 >( ) }
534
- ast:: ty_f64 { size_and_align_of : : <f64 >( ) }
535
- } }
514
+ ast:: ty_path ( _, id) {
515
+ alt tcx. def_map . get ( id) {
516
+ ast:: def_prim_ty ( nty) {
517
+ alt nty {
518
+ ast : : ty_bool { size_and_align_of : : <bool >( ) }
519
+ ast:: ty_int ( m) { alt m {
520
+ ast : : ty_char { size_and_align_of : : <char >( ) }
521
+ ast:: ty_i { size_and_align_of : : <int >( ) }
522
+ ast:: ty_i8 { size_and_align_of : : <i8 >( ) }
523
+ ast:: ty_i16 { size_and_align_of : : <i16 >( ) }
524
+ ast:: ty_i32 { size_and_align_of : : <i32 >( ) }
525
+ ast:: ty_i64 { size_and_align_of : : <i64 >( ) }
526
+ } }
527
+ ast:: ty_uint ( m) { alt m {
528
+ ast : : ty_u { size_and_align_of : : <uint >( ) }
529
+ ast:: ty_u8 { size_and_align_of : : <i8 >( ) }
530
+ ast:: ty_u16 { size_and_align_of : : <u16 >( ) }
531
+ ast:: ty_u32 { size_and_align_of : : <u32 >( ) }
532
+ ast:: ty_u64 { size_and_align_of : : <u64 >( ) }
533
+ } }
534
+ ast:: ty_float ( m) { alt m {
535
+ ast : : ty_f { size_and_align_of : : <float >( ) }
536
+ ast:: ty_f32 { size_and_align_of : : <f32 >( ) }
537
+ ast:: ty_f64 { size_and_align_of : : <f64 >( ) }
538
+ } }
539
+ _ { fail; }
540
+ }
541
+ }
542
+ _ { fail; }
543
+ }
544
+ }
536
545
ast:: ty_box ( _) | ast:: ty_uniq ( _) {
537
546
size_and_align_of :: < ctypes:: uintptr_t > ( )
538
547
}
539
548
ast:: ty_rec ( fields) {
540
549
let total_size = 0 ;
541
550
for field in fields {
542
- let ( size, _) = member_size_and_align ( field. node . mt . ty ) ;
551
+ let ( size, _) = member_size_and_align ( tcx , field. node . mt . ty ) ;
543
552
total_size += size;
544
553
}
545
554
( total_size, 64 ) //XXX different align for other arches?
@@ -551,7 +560,7 @@ fn member_size_and_align(ty: @ast::ty) -> (int, int) {
551
560
}
552
561
}
553
562
554
- fn create_ty ( cx : @crate_ctxt , t : ty:: t , ty : @ast:: ty )
563
+ fn create_ty ( _cx : @crate_ctxt , _t : ty:: t , _ty : @ast:: ty )
555
564
-> @metadata < tydesc_md > {
556
565
/*let cache = get_cache(cx);
557
566
alt cached_metadata::<@metadata<tydesc_md>>(
@@ -560,6 +569,19 @@ fn create_ty(cx: @crate_ctxt, t: ty::t, ty: @ast::ty)
560
569
option::none {}
561
570
}*/
562
571
572
+ /* FIXME I am disabling this code as part of the patch that moves
573
+ * recognition of named builtin types into resolve. I tried to fix
574
+ * it, but it seems to already be broken -- it's only called when
575
+ * --xg is given, and compiling with --xg fails on trivial programs.
576
+ *
577
+ * Generating an ast::ty from a ty::t seems like it should not be
578
+ * needed. It is only done to track spans, but you will not get the
579
+ * right spans anyway -- types tend to refer to stuff defined
580
+ * elsewhere, not be self-contained.
581
+ */
582
+
583
+ fail;
584
+ /*
563
585
fn t_to_ty(cx: @crate_ctxt, t: ty::t, span: span) -> @ast::ty {
564
586
let ty = alt ty::get(t).struct {
565
587
ty::ty_nil { ast::ty_nil }
@@ -628,8 +650,18 @@ fn create_ty(cx: @crate_ctxt, t: ty::t, ty: @ast::ty)
628
650
ret create_pointer_type(cx, t, ty.span, v);
629
651
}
630
652
631
- _ { ret create_basic_type ( cx, t, ty) ; }
653
+ ast::ty_path(_, id) {
654
+ alt ccx_tcx(cx).def_map.get(id) {
655
+ ast::def_prim_ty(pty) {
656
+ ret create_basic_type(cx, t, pty, ty.span);
657
+ }
658
+ _ {}
659
+ }
660
+ }
661
+
662
+ _ {}
632
663
};
664
+ */
633
665
}
634
666
635
667
fn filename_from_span ( cx : @crate_ctxt , sp : codemap:: span ) -> str {
0 commit comments