@@ -94,6 +94,17 @@ pub fn const_vec(cx: @CrateContext, e: @ast::expr, es: &[@ast::expr])
94
94
}
95
95
}
96
96
97
+ fn const_addr_of ( cx : @CrateContext , cv : ValueRef ) -> ValueRef {
98
+ unsafe {
99
+ let gv = do str:: as_c_str ( "const" ) |name| {
100
+ llvm:: LLVMAddGlobal ( cx. llmod , val_ty ( cv) , name)
101
+ } ;
102
+ llvm:: LLVMSetInitializer ( gv, cv) ;
103
+ llvm:: LLVMSetGlobalConstant ( gv, True ) ;
104
+ gv
105
+ }
106
+ }
107
+
97
108
pub fn const_deref ( cx : @CrateContext , v : ValueRef ) -> ValueRef {
98
109
unsafe {
99
110
let v = match cx. const_globals . find ( & ( v as int ) ) {
@@ -355,13 +366,7 @@ fn const_expr_unchecked(cx: @CrateContext, e: @ast::expr) -> ValueRef {
355
366
}
356
367
}
357
368
ast:: expr_addr_of( ast:: m_imm, sub) => {
358
- let cv = const_expr ( cx, sub) ;
359
- let gv = do str:: as_c_str ( "const" ) |name| {
360
- llvm:: LLVMAddGlobal ( cx. llmod , val_ty ( cv) , name)
361
- } ;
362
- llvm:: LLVMSetInitializer ( gv, cv) ;
363
- llvm:: LLVMSetGlobalConstant ( gv, True ) ;
364
- gv
369
+ const_addr_of ( cx, const_expr ( cx, sub) )
365
370
}
366
371
ast:: expr_tup ( es) => {
367
372
let ety = ty:: expr_ty ( cx. tcx , e) ;
0 commit comments