@@ -356,31 +356,7 @@ fn create_basic_type(cx: @CrateContext, t: ty::t, span: span)
356
356
option:: None => ( )
357
357
}
358
358
359
- let ( name, encoding) = match ty:: get ( t) . sty {
360
- ty:: ty_nil | ty:: ty_bot => ( ~"uint", DW_ATE_unsigned ) ,
361
- ty:: ty_bool => ( ~"bool", DW_ATE_boolean ) ,
362
- ty:: ty_int( int_ty) => match int_ty {
363
- ast:: ty_i => ( ~"int", DW_ATE_signed ) ,
364
- ast:: ty_char => ( ~"char", DW_ATE_signed_char ) ,
365
- ast:: ty_i8 => ( ~"i8", DW_ATE_signed ) ,
366
- ast:: ty_i16 => ( ~"i16", DW_ATE_signed ) ,
367
- ast:: ty_i32 => ( ~"i32", DW_ATE_signed ) ,
368
- ast:: ty_i64 => ( ~"i64", DW_ATE_signed )
369
- } ,
370
- ty:: ty_uint( uint_ty) => match uint_ty {
371
- ast:: ty_u => ( ~"uint", DW_ATE_unsigned ) ,
372
- ast:: ty_u8 => ( ~"u8", DW_ATE_unsigned ) ,
373
- ast:: ty_u16 => ( ~"i16", DW_ATE_unsigned ) ,
374
- ast:: ty_u32 => ( ~"u32", DW_ATE_unsigned ) ,
375
- ast:: ty_u64 => ( ~"u64", DW_ATE_unsigned )
376
- } ,
377
- ty:: ty_float( float_ty) => match float_ty {
378
- ast:: ty_f => ( ~"float", DW_ATE_float ) ,
379
- ast:: ty_f32 => ( ~"f32", DW_ATE_float ) ,
380
- ast:: ty_f64 => ( ~"f64", DW_ATE_float )
381
- } ,
382
- _ => cx. sess . bug ( ~"debuginfo:: create_basic_type - t is invalid type")
383
- } ;
359
+ let ( name, encoding) = ( ~"uint", DW_ATE_unsigned ) ;
384
360
385
361
let fname = filename_from_span ( cx, span) ;
386
362
let file_node = create_file ( cx, fname) ;
@@ -497,53 +473,6 @@ fn add_member(cx: @mut StructCtxt,
497
473
cx. total_size += size * 8 ;
498
474
}
499
475
500
- fn create_struct ( cx : @CrateContext , t : ty:: t , fields : ~[ ty:: field ] ,
501
- span : span ) -> @Metadata < TyDescMetadata > {
502
- let fname = filename_from_span ( cx, span) ;
503
- let file_node = create_file ( cx, fname) ;
504
- let scx = create_structure ( file_node, @ty_to_str ( cx. tcx , t) ,
505
- line_from_span ( cx. sess . codemap , span) as int ) ;
506
- for fields. each |field| {
507
- let field_t = field. mt . ty ;
508
- let ty_md = create_ty ( cx, field_t, span) ;
509
- let ( size, align) = size_and_align_of ( cx, field_t) ;
510
- add_member ( scx, * cx. sess . str_of ( field. ident ) ,
511
- line_from_span ( cx. sess . codemap , span) as int ,
512
- size as int , align as int , ty_md. node ) ;
513
- }
514
- let mdval = @Metadata {
515
- node : finish_structure ( scx) ,
516
- data : TyDescMetadata {
517
- hash : ty:: type_id ( t)
518
- }
519
- } ;
520
- return mdval;
521
- }
522
-
523
- fn create_tuple ( cx : @CrateContext , t : ty:: t , elements : ~[ ty:: t ] , span : span )
524
- -> @Metadata < TyDescMetadata > {
525
- let fname = filename_from_span ( cx, span) ;
526
- let file_node = create_file ( cx, fname) ;
527
- let scx = create_structure ( file_node,
528
- cx. sess . str_of (
529
- ( ( /*bad*/ copy cx. dbg_cx ) . get ( ) . names )
530
- ( ~"tuple") ) ,
531
- line_from_span ( cx. sess . codemap , span) as int ) ;
532
- for elements. each |element| {
533
- let ty_md = create_ty ( cx, * element, span) ;
534
- let ( size, align) = size_and_align_of ( cx, * element) ;
535
- add_member ( scx, ~"", line_from_span ( cx. sess . codemap , span) as int ,
536
- size as int , align as int , ty_md. node ) ;
537
- }
538
- let mdval = @Metadata {
539
- node : finish_structure ( scx) ,
540
- data : TyDescMetadata {
541
- hash : ty:: type_id ( t)
542
- }
543
- } ;
544
- return mdval;
545
- }
546
-
547
476
fn create_boxed_type ( cx : @CrateContext , outer : ty:: t , _inner : ty:: t ,
548
477
span : span , boxed : @Metadata < TyDescMetadata > )
549
478
-> @Metadata < TyDescMetadata > {
@@ -609,10 +538,11 @@ fn create_composite_type(type_tag: int, name: &str, file: ValueRef,
609
538
}
610
539
611
540
fn create_vec ( cx : @CrateContext , vec_t : ty:: t , elem_t : ty:: t ,
612
- vec_ty_span : codemap:: span ) -> @Metadata < TyDescMetadata > {
541
+ vec_ty_span : codemap:: span , elem_ty : @ast:: Ty )
542
+ -> @Metadata < TyDescMetadata > {
613
543
let fname = filename_from_span ( cx, vec_ty_span) ;
614
544
let file_node = create_file ( cx, fname) ;
615
- let elem_ty_md = create_ty ( cx, elem_t, vec_ty_span ) ;
545
+ let elem_ty_md = create_ty ( cx, elem_t, elem_ty ) ;
616
546
let scx = create_structure ( file_node,
617
547
@/* bad* / copy ty_to_str ( cx. tcx , vec_t) , 0 ) ;
618
548
let size_t_type = create_basic_type ( cx, ty:: mk_uint ( cx. tcx ) , vec_ty_span) ;
@@ -637,60 +567,94 @@ fn create_vec(cx: @CrateContext, vec_t: ty::t, elem_t: ty::t,
637
567
}
638
568
}
639
569
640
- fn create_ty( cx : @CrateContext , t : ty:: t , span : span )
570
+ fn create_ty ( _cx : @CrateContext , _t : ty:: t , _ty : @ast :: Ty )
641
571
-> @Metadata < TyDescMetadata > {
642
- debug ! ( "create_ty: %?" , ty:: get( t) ) ;
643
572
/*let cache = get_cache(cx);
644
573
match cached_metadata::<@Metadata<TyDescMetadata>>(
645
574
cache, tg, {|md| t == md.data.hash}) {
646
575
option::Some(md) { return md; }
647
576
option::None {}
648
577
}*/
649
578
650
- let sty = copy ty:: get ( t) . sty ;
651
- match copy sty {
652
- ty:: ty_nil | ty:: ty_bot | ty:: ty_bool | ty:: ty_int( _) | ty:: ty_uint( _)
653
- | ty:: ty_float( _) => create_basic_type ( cx, t, span) ,
654
- ty:: ty_estr( _vstore) => {
655
- cx. sess . span_bug ( span, ~"debuginfo for estr NYI ")
656
- } ,
657
- ty:: ty_enum( _did, _substs) => {
658
- cx. sess . span_bug ( span, ~"debuginfo for enum NYI ")
659
- }
660
- ty:: ty_box( _mt) => {
661
- cx. sess . span_bug ( span, ~"debuginfo for box NYI ")
662
- } ,
663
- ty:: ty_uniq( _mt) => {
664
- cx. sess . span_bug ( span, ~"debuginfo for uniq NYI ")
665
- } ,
666
- ty:: ty_evec( _mt, _vstore) => {
667
- cx. sess . span_bug ( span, ~"debuginfo for evec NYI ")
668
- } ,
669
- ty:: ty_ptr( mt) => {
670
- let pointee = create_ty ( cx, mt. ty , span) ;
671
- create_pointer_type ( cx, t, span, pointee)
672
- } ,
673
- ty:: ty_rptr ( _region, _mt) => {
674
- cx. sess . span_bug ( span, ~"debuginfo for rptr NYI ")
675
- } ,
676
- ty:: ty_bare_fn( _barefnty) => {
677
- cx. sess . span_bug ( span, ~"debuginfo for bare_fn NYI ")
678
- } ,
679
- ty:: ty_closure( _closurety) => {
680
- cx. sess . span_bug ( span, ~"debuginfo for closure NYI ")
681
- } ,
682
- ty:: ty_trait( _did, _substs, _vstore) => {
683
- cx. sess . span_bug ( span, ~"debuginfo for trait NYI ")
684
- } ,
685
- ty:: ty_struct( did, substs) => {
686
- let fields = ty:: struct_fields ( cx. tcx , did, & substs) ;
687
- create_struct ( cx, t, fields, span)
688
- } ,
689
- ty:: ty_tup ( elements) => {
690
- create_tuple ( cx, t, elements, span)
691
- } ,
692
- _ => cx. sess . bug ( ~"debuginfo: unexpected type in create_ty")
579
+ /* FIXME (#2012): disabled this code as part of the patch that moves
580
+ * recognition of named builtin types into resolve. I tried to fix
581
+ * it, but it seems to already be broken -- it's only called when
582
+ * --xg is given, and compiling with --xg fails on trivial programs.
583
+ *
584
+ * Generating an ast::ty from a ty::t seems like it should not be
585
+ * needed. It is only done to track spans, but you will not get the
586
+ * right spans anyway -- types tend to refer to stuff defined
587
+ * elsewhere, not be self-contained.
588
+ */
589
+
590
+ fail ! ( ) ;
591
+ /*
592
+ fn t_to_ty(cx: CrateContext, t: ty::t, span: span) -> @ast::ty {
593
+ let ty = match ty::get(t).struct {
594
+ ty::ty_nil { ast::ty_nil }
595
+ ty::ty_bot { ast::ty_bot }
596
+ ty::ty_bool { ast::ty_bool }
597
+ ty::ty_int(t) { ast::ty_int(t) }
598
+ ty::ty_float(t) { ast::ty_float(t) }
599
+ ty::ty_uint(t) { ast::ty_uint(t) }
600
+ ty::ty_box(mt) { ast::ty_box({ty: t_to_ty(cx, mt.ty, span),
601
+ mutbl: mt.mutbl}) }
602
+ ty::ty_uniq(mt) { ast::ty_uniq({ty: t_to_ty(cx, mt.ty, span),
603
+ mutbl: mt.mutbl}) }
604
+ ty::ty_vec(mt) { ast::ty_vec({ty: t_to_ty(cx, mt.ty, span),
605
+ mutbl: mt.mutbl}) }
606
+ _ {
607
+ cx.sess.span_bug(span, "t_to_ty: Can't handle this type");
608
+ }
609
+ };
610
+ return @{node: ty, span: span};
693
611
}
612
+
613
+ match ty.node {
614
+ ast::ty_box(mt) {
615
+ let inner_t = match ty::get(t).struct {
616
+ ty::ty_box(boxed) { boxed.ty }
617
+ _ { cx.sess.span_bug(ty.span, "t_to_ty was incoherent"); }
618
+ };
619
+ let md = create_ty(cx, inner_t, mt.ty);
620
+ let box = create_boxed_type(cx, t, inner_t, ty.span, md);
621
+ return create_pointer_type(cx, t, ty.span, box);
622
+ }
623
+
624
+ ast::ty_uniq(mt) {
625
+ let inner_t = match ty::get(t).struct {
626
+ ty::ty_uniq(boxed) { boxed.ty }
627
+ // Hoping we'll have a way to eliminate this check soon.
628
+ _ { cx.sess.span_bug(ty.span, "t_to_ty was incoherent"); }
629
+ };
630
+ let md = create_ty(cx, inner_t, mt.ty);
631
+ return create_pointer_type(cx, t, ty.span, md);
632
+ }
633
+
634
+ ast::ty_infer {
635
+ let inferred = t_to_ty(cx, t, ty.span);
636
+ return create_ty(cx, t, inferred);
637
+ }
638
+
639
+ ast::ty_vec(mt) {
640
+ let inner_t = ty::sequence_element_type(cx.tcx, t);
641
+ let inner_ast_t = t_to_ty(cx, inner_t, mt.ty.span);
642
+ let v = create_vec(cx, t, inner_t, ty.span, inner_ast_t);
643
+ return create_pointer_type(cx, t, ty.span, v);
644
+ }
645
+
646
+ ast::ty_path(_, id) {
647
+ match cx.tcx.def_map.get(id) {
648
+ ast::def_prim_ty(pty) {
649
+ return create_basic_type(cx, t, pty, ty.span);
650
+ }
651
+ _ {}
652
+ }
653
+ }
654
+
655
+ _ {}
656
+ };
657
+ */
694
658
}
695
659
696
660
fn filename_from_span ( cx : @CrateContext , sp : codemap:: span ) -> ~str {
@@ -729,7 +693,7 @@ pub fn create_local_var(bcx: block, local: @ast::local)
729
693
};
730
694
let loc = cx.sess.codemap.lookup_char_pos(local.span.lo);
731
695
let ty = node_id_type(bcx, local.node.id);
732
- let tymd = create_ty(cx, ty, local.node.ty.span );
696
+ let tymd = create_ty(cx, ty, local.node.ty);
733
697
let filemd = create_file(cx, /*bad*/copy loc.file.name);
734
698
let context = match bcx.parent {
735
699
None => create_function(bcx.fcx).node,
@@ -779,11 +743,8 @@ pub fn create_arg(bcx: block, arg: ast::arg, sp: span)
779
743
}
780
744
781
745
let loc = cx.sess.codemap.lookup_char_pos(sp.lo);
782
- if loc.file.name == ~" <intrinsic>" {
783
- return None;
784
- }
785
746
let ty = node_id_type(bcx, arg.id);
786
- let tymd = create_ty(cx, ty, arg.ty.span );
747
+ let tymd = create_ty(cx, ty, arg.ty);
787
748
let filemd = create_file(cx, /*bad*/copy loc.file.name);
788
749
let context = create_function(bcx.fcx);
789
750
@@ -895,8 +856,7 @@ pub fn create_function(fcx: fn_ctxt) -> @Metadata<SubProgramMetadata> {
895
856
let ty_node = if cx. sess . opts . extra_debuginfo {
896
857
match ret_ty. node {
897
858
ast:: ty_nil => llnull ( ) ,
898
- _ => create_ty ( cx, ty:: node_id_to_type ( cx. tcx , id) ,
899
- ret_ty. span ) . node
859
+ _ => create_ty ( cx, ty:: node_id_to_type ( cx. tcx , id) , ret_ty) . node
900
860
}
901
861
} else {
902
862
llnull ( )
0 commit comments