@@ -293,7 +293,7 @@ fn type_of_fn(@crate_ctxt cx,
293
293
auto ty_param_count = typeck. count_ty_params ( fn_ty) ;
294
294
auto i = 0 u;
295
295
while ( i < ty_param_count) {
296
- atys += T_tydesc ( ) ;
296
+ atys += T_ptr ( T_tydesc ( ) ) ;
297
297
i += 1 u;
298
298
}
299
299
@@ -578,15 +578,28 @@ fn trans_malloc(@block_ctxt cx, @typeck.ty t) -> result {
578
578
// returns an LLVM ValueRef of that field from the tydesc, generating the
579
579
// tydesc if necessary.
580
580
fn field_of_tydesc ( @block_ctxt cx , @typeck . ty ty, int field ) -> ValueRef {
581
- auto tydesc = get_tydesc ( cx. fcx . ccx , ty) ;
581
+ auto tydesc = get_tydesc ( cx, ty) ;
582
582
ret cx. build . GEP ( tydesc, vec ( C_int ( 0 ) , C_int ( field) ) ) ;
583
583
}
584
584
585
- fn get_tydesc ( @crate_ctxt cx , @typeck . ty ty) -> ValueRef {
586
- if ( !cx. tydescs . contains_key ( ty) ) {
587
- make_tydesc ( cx, ty) ;
585
+ fn get_tydesc ( & @block_ctxt cx , @typeck . ty ty) -> ValueRef {
586
+ // Is the supplied type a type param? If so, return the passed-in tydesc.
587
+ alt ( typeck. type_param ( ty) ) {
588
+ case ( some[ ast. def_id ] ( ?id) ) { ret cx. fcx . lltydescs . get ( id) ; }
589
+ case ( none[ ast. def_id ] ) { /* fall through */ }
588
590
}
589
- ret cx. tydescs . get ( ty) ;
591
+
592
+ // Does it contain a type param? If so, generate a derived tydesc.
593
+ if ( typeck. count_ty_params ( ty) > 0 u) {
594
+ log "TODO: trans.get_tydesc(): generate a derived type descriptor" ;
595
+ fail;
596
+ }
597
+
598
+ // Otherwise, generate a tydesc if necessary, and return it.
599
+ if ( !cx. fcx . ccx . tydescs . contains_key ( ty) ) {
600
+ make_tydesc ( cx. fcx . ccx , ty) ;
601
+ }
602
+ ret cx. fcx . ccx . tydescs . get ( ty) ;
590
603
}
591
604
592
605
fn make_tydesc ( @crate_ctxt cx , @typeck . ty ty) {
0 commit comments