@@ -138,6 +138,7 @@ use middle::trans::consts;
138138use middle:: trans:: controlflow;
139139use middle:: trans:: datum:: * ;
140140use middle:: trans:: debuginfo;
141+ use middle:: trans:: inline;
141142use middle:: trans:: machine;
142143use middle:: trans:: meth;
143144use middle:: trans:: tvec;
@@ -984,15 +985,54 @@ fn trans_lvalue_unadjusted(bcx: block, expr: @ast::expr) -> DatumBlock {
984985 match def {
985986 ast:: def_const( did) => {
986987 let const_ty = expr_ty ( bcx, ref_expr) ;
987- let val = if did. crate == ast:: local_crate {
988+
989+ #[ cfg( stage0) ]
990+ fn get_did ( _ccx : @CrateContext , did : ast:: def_id )
991+ -> ast:: def_id {
992+ did
993+ }
994+
995+ #[ cfg( stage1) ]
996+ #[ cfg( stage2) ]
997+ #[ cfg( stage3) ]
998+ fn get_did ( ccx : @CrateContext , did : ast:: def_id )
999+ -> ast:: def_id {
1000+ if did. crate != ast:: local_crate {
1001+ inline:: maybe_instantiate_inline ( ccx, did, true )
1002+ } else {
1003+ did
1004+ }
1005+ }
1006+
1007+ #[ cfg( stage0) ]
1008+ fn get_val ( bcx : block , did : ast:: def_id , const_ty : ty:: t )
1009+ -> ValueRef {
1010+ let ccx = bcx. ccx ( ) ;
1011+ if did. crate == ast:: local_crate {
1012+ // The LLVM global has the type of its initializer,
1013+ // which may not be equal to the enum's type for
1014+ // non-C-like enums.
1015+ PointerCast ( bcx, base:: get_item_val ( ccx, did. node ) ,
1016+ T_ptr ( type_of ( bcx. ccx ( ) , const_ty) ) )
1017+ } else {
1018+ base:: trans_external_path ( ccx, did, const_ty)
1019+ }
1020+ }
1021+
1022+ #[ cfg( stage1) ]
1023+ #[ cfg( stage2) ]
1024+ #[ cfg( stage3) ]
1025+ fn get_val ( bcx : block , did : ast:: def_id , const_ty : ty:: t )
1026+ -> ValueRef {
9881027 // The LLVM global has the type of its initializer,
9891028 // which may not be equal to the enum's type for
9901029 // non-C-like enums.
991- PointerCast ( bcx, base:: get_item_val ( ccx, did. node ) ,
1030+ PointerCast ( bcx, base:: get_item_val ( bcx . ccx ( ) , did. node ) ,
9921031 T_ptr ( type_of ( bcx. ccx ( ) , const_ty) ) )
993- } else {
994- base:: trans_external_path ( ccx, did, const_ty)
995- } ;
1032+ }
1033+
1034+ let did = get_did ( ccx, did) ;
1035+ let val = get_val ( bcx, did, const_ty) ;
9961036 DatumBlock {
9971037 bcx : bcx,
9981038 datum : Datum { val : val,
0 commit comments