@@ -28,6 +28,7 @@ use print::pp;
28
28
use print:: pprust;
29
29
30
30
use std:: cast;
31
+ use std:: cell:: RefCell ;
31
32
use std:: char;
32
33
use std:: str;
33
34
use std:: io;
@@ -73,17 +74,23 @@ pub struct ps {
73
74
comments : Option < ~[ comments:: cmnt ] > ,
74
75
literals : Option < ~[ comments:: lit ] > ,
75
76
cur_cmnt_and_lit : CurrentCommentAndLiteral ,
76
- boxes : @ mut ~[ pp:: breaks ] ,
77
+ boxes : RefCell < ~[ pp:: breaks ] > ,
77
78
ann : @pp_ann
78
79
}
79
80
80
81
pub fn ibox ( s : & mut ps , u : uint ) {
81
- s. boxes . push ( pp:: inconsistent) ;
82
+ {
83
+ let mut boxes = s. boxes . borrow_mut ( ) ;
84
+ boxes. get ( ) . push ( pp:: inconsistent) ;
85
+ }
82
86
pp:: ibox ( & mut s. s , u) ;
83
87
}
84
88
85
89
pub fn end ( s : & mut ps ) {
86
- s. boxes . pop ( ) ;
90
+ {
91
+ let mut boxes = s. boxes . borrow_mut ( ) ;
92
+ boxes. get ( ) . pop ( ) ;
93
+ }
87
94
pp:: end ( & mut s. s ) ;
88
95
}
89
96
@@ -105,7 +112,7 @@ pub fn rust_printer_annotated(writer: ~io::Writer,
105
112
cur_cmnt : 0 ,
106
113
cur_lit : 0
107
114
} ,
108
- boxes : @ mut ~[ ] ,
115
+ boxes : RefCell :: new ( ~[ ] ) ,
109
116
ann : ann
110
117
} ;
111
118
}
@@ -148,7 +155,7 @@ pub fn print_crate(cm: @CodeMap,
148
155
cur_cmnt : 0 ,
149
156
cur_lit : 0
150
157
} ,
151
- boxes : @ mut ~[ ] ,
158
+ boxes : RefCell :: new ( ~[ ] ) ,
152
159
ann : ann
153
160
} ;
154
161
print_crate_ ( & mut s, crate ) ;
@@ -243,13 +250,19 @@ pub fn variant_to_str(var: &ast::variant, intr: @ident_interner) -> ~str {
243
250
}
244
251
245
252
pub fn cbox ( s : & mut ps , u : uint ) {
246
- s. boxes . push ( pp:: consistent) ;
253
+ {
254
+ let mut boxes = s. boxes . borrow_mut ( ) ;
255
+ boxes. get ( ) . push ( pp:: consistent) ;
256
+ }
247
257
pp:: cbox ( & mut s. s , u) ;
248
258
}
249
259
250
260
// "raw box"
251
261
pub fn rbox ( s : & mut ps , u : uint , b : pp:: breaks ) {
252
- s. boxes . push ( b) ;
262
+ {
263
+ let mut boxes = s. boxes . borrow_mut ( ) ;
264
+ boxes. get ( ) . push ( b) ;
265
+ }
253
266
pp:: rbox ( & mut s. s , u, b) ;
254
267
}
255
268
@@ -306,10 +319,10 @@ pub fn is_bol(s: &mut ps) -> bool {
306
319
}
307
320
308
321
pub fn in_cbox ( s : & mut ps ) -> bool {
309
- let boxes = & * s. boxes ;
310
- let len = boxes. len ( ) ;
322
+ let boxes = s. boxes . borrow ( ) ;
323
+ let len = boxes. get ( ) . len ( ) ;
311
324
if len == 0 u { return false ; }
312
- return boxes[ len - 1 u] == pp:: consistent;
325
+ return boxes. get ( ) [ len - 1 u] == pp:: consistent;
313
326
}
314
327
315
328
pub fn hardbreak_if_not_bol ( s : & mut ps ) {
0 commit comments