@@ -968,7 +968,10 @@ fn trans_lvalue_unadjusted(bcx: block, expr: @ast::expr) -> DatumBlock {
968
968
}
969
969
970
970
fn get_val ( bcx : block , did : ast:: def_id , const_ty : ty:: t )
971
- -> ValueRef {
971
+ -> ValueRef {
972
+ // For external constants, we don't inline.
973
+ let extern_const_values =
974
+ & mut * bcx. ccx ( ) . extern_const_values ;
972
975
if did. crate == ast:: local_crate {
973
976
// The LLVM global has the type of its initializer,
974
977
// which may not be equal to the enum's type for
@@ -977,25 +980,24 @@ fn trans_lvalue_unadjusted(bcx: block, expr: @ast::expr) -> DatumBlock {
977
980
base:: get_item_val ( bcx. ccx ( ) , did. node ) ,
978
981
T_ptr ( type_of ( bcx. ccx ( ) , const_ty) ) )
979
982
} else {
980
- // For external constants, we don't inline.
981
- match bcx. ccx ( ) . extern_const_values . find ( & did) {
982
- None => {
983
- unsafe {
984
- let llty = type_of ( bcx. ccx ( ) , const_ty) ;
985
- let symbol = csearch:: get_symbol (
986
- bcx. ccx ( ) . sess . cstore ,
987
- did) ;
988
- let llval = llvm:: LLVMAddGlobal (
989
- bcx. ccx ( ) . llmod ,
990
- llty,
991
- transmute :: < & u8 , * i8 > ( & symbol[ 0 ] ) ) ;
992
- bcx. ccx ( ) . extern_const_values . insert (
993
- did,
994
- llval) ;
995
- llval
996
- }
983
+ match extern_const_values. find ( & did) {
984
+ None => { } // Continue.
985
+ Some ( llval) => {
986
+ return * llval;
997
987
}
998
- Some ( llval) => * llval
988
+ }
989
+
990
+ unsafe {
991
+ let llty = type_of ( bcx. ccx ( ) , const_ty) ;
992
+ let symbol = csearch:: get_symbol (
993
+ bcx. ccx ( ) . sess . cstore ,
994
+ did) ;
995
+ let llval = llvm:: LLVMAddGlobal (
996
+ bcx. ccx ( ) . llmod ,
997
+ llty,
998
+ transmute :: < & u8 , * i8 > ( & symbol[ 0 ] ) ) ;
999
+ extern_const_values. insert ( did, llval) ;
1000
+ llval
999
1001
}
1000
1002
}
1001
1003
}
0 commit comments