@@ -319,6 +319,17 @@ impl Context {
319
319
}
320
320
}
321
321
322
+ /// These attributes are applied to all statics that this syntax extension
323
+ /// will generate.
324
+ fn static_attrs ( & self ) -> ~[ ast:: Attribute ] {
325
+ // Flag statics as `address_insignificant` so LLVM can merge duplicate
326
+ // globals as much as possible (which we're generating a whole lot of).
327
+ let unnamed = self . ecx . meta_word ( self . fmtsp , @"address_insignificant") ;
328
+ let unnamed = self . ecx . attribute ( self . fmtsp , unnamed) ;
329
+
330
+ return ~[ unnamed] ;
331
+ }
332
+
322
333
/// Translate a `parse::Piece` to a static `rt::Piece`
323
334
fn trans_piece ( & mut self , piece : & parse:: Piece ) -> @ast:: Expr {
324
335
let sp = self . fmtsp ;
@@ -444,14 +455,9 @@ impl Context {
444
455
~[ ]
445
456
) , None ) ;
446
457
let st = ast:: item_static ( ty, ast:: MutImmutable , method) ;
447
- let static_name = self . ecx . ident_of ( format ! ( "__static_method_ {}" ,
458
+ let static_name = self . ecx . ident_of ( format ! ( "__STATIC_METHOD_ {}" ,
448
459
self . method_statics. len( ) ) ) ;
449
- // Flag these statics as `address_insignificant` so LLVM can
450
- // merge duplicate globals as much as possible (which we're
451
- // generating a whole lot of).
452
- let unnamed = self . ecx . meta_word ( self . fmtsp , @"address_insignificant") ;
453
- let unnamed = self . ecx . attribute ( self . fmtsp , unnamed) ;
454
- let item = self . ecx . item ( sp, static_name, ~[ unnamed] , st) ;
460
+ let item = self . ecx . item ( sp, static_name, self . static_attrs ( ) , st) ;
455
461
self . method_statics . push ( item) ;
456
462
self . ecx . expr_ident ( sp, static_name)
457
463
} ;
@@ -572,11 +578,9 @@ impl Context {
572
578
) ;
573
579
let ty = self . ecx . ty ( self . fmtsp , ty) ;
574
580
let st = ast:: item_static ( ty, ast:: MutImmutable , fmt) ;
575
- let static_name = self . ecx . ident_of ( "__static_fmtstr" ) ;
576
- // see above comment for `address_insignificant` and why we do it
577
- let unnamed = self . ecx . meta_word ( self . fmtsp , @"address_insignificant") ;
578
- let unnamed = self . ecx . attribute ( self . fmtsp , unnamed) ;
579
- let item = self . ecx . item ( self . fmtsp , static_name, ~[ unnamed] , st) ;
581
+ let static_name = self . ecx . ident_of ( "__STATIC_FMTSTR" ) ;
582
+ let item = self . ecx . item ( self . fmtsp , static_name,
583
+ self . static_attrs ( ) , st) ;
580
584
let decl = respan ( self . fmtsp , ast:: DeclItem ( item) ) ;
581
585
lets. push ( @respan ( self . fmtsp , ast:: StmtDecl ( @decl, ast:: DUMMY_NODE_ID ) ) ) ;
582
586
0 commit comments