File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -347,6 +347,15 @@ fn val_str(type_names tn, ValueRef v) -> str {
347
347
ret ty_str ( tn, val_ty ( v) ) ;
348
348
}
349
349
350
+ // Returns the nth element of the given LLVM structure type.
351
+ fn struct_elt ( TypeRef llstructty , uint n) -> TypeRef {
352
+ auto elt_count = llvm:: LLVMCountStructElementTypes ( llstructty) ;
353
+ assert ( n < elt_count) ;
354
+ auto elt_tys = vec:: init_elt ( T_nil ( ) , elt_count) ;
355
+ llvm:: LLVMGetStructElementTypes ( llstructty, vec:: buf ( elt_tys) ) ;
356
+ ret llvm:: LLVMGetElementType ( elt_tys. ( n) ) ;
357
+ }
358
+
350
359
351
360
// LLVM type constructors.
352
361
@@ -7686,10 +7695,7 @@ fn trans_mod(@local_ctxt cx, &ast::_mod m) {
7686
7695
7687
7696
fn get_pair_fn_ty( TypeRef llpairty) -> TypeRef {
7688
7697
// Bit of a kludge: pick the fn typeref out of the pair.
7689
- let vec[ TypeRef ] pair_tys = [ T_nil ( ) , T_nil ( ) ] ;
7690
- llvm:: LLVMGetStructElementTypes ( llpairty,
7691
- vec:: buf[ TypeRef ] ( pair_tys) ) ;
7692
- ret llvm:: LLVMGetElementType ( pair_tys. ( 0 ) ) ;
7698
+ ret struct_elt( llpairty, 0 u) ;
7693
7699
}
7694
7700
7695
7701
fn decl_fn_and_pair( & @crate_ctxt ccx, & span sp,
You can’t perform that action at this time.
0 commit comments