@@ -155,13 +155,13 @@ fn live_node_kind_to_str(lnk: LiveNodeKind, cx: ty::ctxt) -> ~str {
155
155
156
156
struct LivenessVisitor ;
157
157
158
- impl Visitor < @mut IrMaps > for LivenessVisitor {
159
- fn visit_fn ( & mut self , fk : & fn_kind , fd : & fn_decl , b : P < Block > , s : Span , n : NodeId , e : @mut IrMaps ) {
158
+ impl Visitor < @IrMaps > for LivenessVisitor {
159
+ fn visit_fn ( & mut self , fk : & fn_kind , fd : & fn_decl , b : P < Block > , s : Span , n : NodeId , e : @IrMaps ) {
160
160
visit_fn ( self , fk, fd, b, s, n, e) ;
161
161
}
162
- fn visit_local ( & mut self , l : @Local , e : @mut IrMaps ) { visit_local ( self , l, e) ; }
163
- fn visit_expr ( & mut self , ex : @Expr , e : @mut IrMaps ) { visit_expr ( self , ex, e) ; }
164
- fn visit_arm ( & mut self , a : & Arm , e : @mut IrMaps ) { visit_arm ( self , a, e) ; }
162
+ fn visit_local ( & mut self , l : @Local , e : @IrMaps ) { visit_local ( self , l, e) ; }
163
+ fn visit_expr ( & mut self , ex : @Expr , e : @IrMaps ) { visit_expr ( self , ex, e) ; }
164
+ fn visit_arm ( & mut self , a : & Arm , e : @IrMaps ) { visit_arm ( self , a, e) ; }
165
165
}
166
166
167
167
pub fn check_crate ( tcx : ty:: ctxt ,
@@ -170,9 +170,7 @@ pub fn check_crate(tcx: ty::ctxt,
170
170
crate : & Crate ) {
171
171
let mut visitor = LivenessVisitor ;
172
172
173
- let initial_maps = @mut IrMaps ( tcx,
174
- method_map,
175
- capture_map) ;
173
+ let initial_maps = @IrMaps ( tcx, method_map, capture_map) ;
176
174
visit:: walk_crate ( & mut visitor, crate , initial_maps) ;
177
175
tcx. sess . abort_if_errors ( ) ;
178
176
}
@@ -273,7 +271,7 @@ fn IrMaps(tcx: ty::ctxt,
273
271
}
274
272
275
273
impl IrMaps {
276
- pub fn add_live_node ( & mut self , lnk : LiveNodeKind ) -> LiveNode {
274
+ pub fn add_live_node ( & self , lnk : LiveNodeKind ) -> LiveNode {
277
275
let num_live_nodes = self . num_live_nodes . get ( ) ;
278
276
let ln = LiveNode ( num_live_nodes) ;
279
277
let mut lnks = self . lnks . borrow_mut ( ) ;
@@ -286,17 +284,15 @@ impl IrMaps {
286
284
ln
287
285
}
288
286
289
- pub fn add_live_node_for_node ( & mut self ,
290
- node_id : NodeId ,
291
- lnk : LiveNodeKind ) {
287
+ pub fn add_live_node_for_node ( & self , node_id : NodeId , lnk : LiveNodeKind ) {
292
288
let ln = self . add_live_node ( lnk) ;
293
289
let mut live_node_map = self . live_node_map . borrow_mut ( ) ;
294
290
live_node_map. get ( ) . insert ( node_id, ln) ;
295
291
296
292
debug ! ( "{} is node {}" , ln. to_str( ) , node_id) ;
297
293
}
298
294
299
- pub fn add_variable ( & mut self , vk : VarKind ) -> Variable {
295
+ pub fn add_variable ( & self , vk : VarKind ) -> Variable {
300
296
let v = Variable ( self . num_vars . get ( ) ) ;
301
297
{
302
298
let mut var_kinds = self . var_kinds . borrow_mut ( ) ;
@@ -317,7 +313,7 @@ impl IrMaps {
317
313
v
318
314
}
319
315
320
- pub fn variable ( & mut self , node_id : NodeId , span : Span ) -> Variable {
316
+ pub fn variable ( & self , node_id : NodeId , span : Span ) -> Variable {
321
317
let variable_map = self . variable_map . borrow ( ) ;
322
318
match variable_map. get ( ) . find ( & node_id) {
323
319
Some ( & var) => var,
@@ -328,7 +324,7 @@ impl IrMaps {
328
324
}
329
325
}
330
326
331
- pub fn variable_name ( & mut self , var : Variable ) -> @str {
327
+ pub fn variable_name ( & self , var : Variable ) -> @str {
332
328
let var_kinds = self . var_kinds . borrow ( ) ;
333
329
match var_kinds. get ( ) [ * var] {
334
330
Local ( LocalInfo { ident : nm, .. } ) | Arg ( _, nm) => {
@@ -338,12 +334,12 @@ impl IrMaps {
338
334
}
339
335
}
340
336
341
- pub fn set_captures(&mut self, node_id: NodeId, cs: ~[CaptureInfo]) {
337
+ pub fn set_captures(&self, node_id: NodeId, cs: ~[CaptureInfo]) {
342
338
let mut capture_info_map = self.capture_info_map.borrow_mut();
343
339
capture_info_map.get().insert(node_id, @cs);
344
340
}
345
341
346
- pub fn captures(&mut self, expr: &Expr) -> @~[CaptureInfo] {
342
+ pub fn captures(&self, expr: &Expr) -> @~[CaptureInfo] {
347
343
let capture_info_map = self.capture_info_map.borrow();
348
344
match capture_info_map.get().find(&expr.id) {
349
345
Some(&caps) => caps,
@@ -353,7 +349,7 @@ impl IrMaps {
353
349
}
354
350
}
355
351
356
- pub fn lnk ( & mut self , ln : LiveNode ) -> LiveNodeKind {
352
+ pub fn lnk ( & self , ln : LiveNode ) -> LiveNodeKind {
357
353
let lnks = self . lnks . borrow ( ) ;
358
354
lnks. get ( ) [ * ln]
359
355
}
@@ -380,14 +376,12 @@ fn visit_fn(v: &mut LivenessVisitor,
380
376
body : P < Block > ,
381
377
sp : Span ,
382
378
id : NodeId ,
383
- this : @mut IrMaps ) {
379
+ this : @IrMaps ) {
384
380
debug ! ( "visit_fn: id={}" , id) ;
385
381
let _i = :: util:: common:: indenter ( ) ;
386
382
387
383
// swap in a new set of IR maps for this function body:
388
- let fn_maps = @mut IrMaps ( this. tcx ,
389
- this. method_map ,
390
- this. capture_map ) ;
384
+ let fn_maps = @IrMaps ( this. tcx , this. method_map , this. capture_map ) ;
391
385
392
386
unsafe {
393
387
debug ! ( "creating fn_maps: {}" , transmute:: <& IrMaps , * IrMaps >( fn_maps) ) ;
@@ -441,7 +435,7 @@ fn visit_fn(v: &mut LivenessVisitor,
441
435
lsets. warn_about_unused_args ( decl, entry_ln) ;
442
436
}
443
437
444
- fn visit_local ( v : & mut LivenessVisitor , local : @Local , this : @mut IrMaps ) {
438
+ fn visit_local ( v : & mut LivenessVisitor , local : @Local , this : @IrMaps ) {
445
439
let def_map = this. tcx . def_map ;
446
440
pat_util:: pat_bindings ( def_map, local. pat , |bm, p_id, sp, path| {
447
441
debug ! ( "adding local variable {}" , p_id) ;
@@ -465,7 +459,7 @@ fn visit_local(v: &mut LivenessVisitor, local: @Local, this: @mut IrMaps) {
465
459
visit:: walk_local ( v, local, this) ;
466
460
}
467
461
468
- fn visit_arm ( v : & mut LivenessVisitor , arm : & Arm , this : @mut IrMaps ) {
462
+ fn visit_arm ( v : & mut LivenessVisitor , arm : & Arm , this : @IrMaps ) {
469
463
let def_map = this. tcx . def_map ;
470
464
for pat in arm. pats . iter ( ) {
471
465
pat_util:: pat_bindings ( def_map, * pat, |bm, p_id, sp, path| {
@@ -488,7 +482,7 @@ fn visit_arm(v: &mut LivenessVisitor, arm: &Arm, this: @mut IrMaps) {
488
482
visit:: walk_arm ( v, arm, this) ;
489
483
}
490
484
491
- fn visit_expr ( v : & mut LivenessVisitor , expr : @Expr , this : @mut IrMaps ) {
485
+ fn visit_expr ( v : & mut LivenessVisitor , expr : @Expr , this : @IrMaps ) {
492
486
match expr. node {
493
487
// live nodes required for uses or definitions of variables:
494
488
ExprPath ( _) | ExprSelf => {
@@ -594,7 +588,7 @@ type LiveNodeMap = @RefCell<HashMap<NodeId, LiveNode>>;
594
588
595
589
pub struct Liveness {
596
590
tcx : ty:: ctxt ,
597
- ir : @mut IrMaps ,
591
+ ir : @IrMaps ,
598
592
s : Specials ,
599
593
successors : @mut ~[ LiveNode ] ,
600
594
users : @mut ~[ Users ] ,
@@ -608,7 +602,7 @@ pub struct Liveness {
608
602
cont_ln : LiveNodeMap
609
603
}
610
604
611
- fn Liveness ( ir : @mut IrMaps , specials : Specials ) -> Liveness {
605
+ fn Liveness ( ir : @IrMaps , specials : Specials ) -> Liveness {
612
606
Liveness {
613
607
ir : ir,
614
608
tcx : ir. tcx ,
@@ -626,7 +620,7 @@ fn Liveness(ir: @mut IrMaps, specials: Specials) -> Liveness {
626
620
627
621
impl Liveness {
628
622
pub fn live_node ( & self , node_id : NodeId , span : Span ) -> LiveNode {
629
- let ir: & mut IrMaps = self . ir ;
623
+ let ir: & IrMaps = self . ir ;
630
624
let live_node_map = ir. live_node_map . borrow ( ) ;
631
625
match live_node_map. get ( ) . find ( & node_id) {
632
626
Some ( & ln) => ln,
0 commit comments