Skip to content

Commit b5fafe1

Browse files
committed
---
yaml --- r: 147620 b: refs/heads/try2 c: be67ace h: refs/heads/master v: v3
1 parent 69e09d7 commit b5fafe1

File tree

2 files changed

+23
-29
lines changed

2 files changed

+23
-29
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 810177c78709e114f31ad16540f51b17fb6f3b98
8+
refs/heads/try2: be67aceaeb849233daf6a3ee765be67f5e797e30
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustc/middle/liveness.rs

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,13 @@ fn live_node_kind_to_str(lnk: LiveNodeKind, cx: ty::ctxt) -> ~str {
155155

156156
struct LivenessVisitor;
157157

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) {
160160
visit_fn(self, fk, fd, b, s, n, e);
161161
}
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); }
165165
}
166166

167167
pub fn check_crate(tcx: ty::ctxt,
@@ -170,9 +170,7 @@ pub fn check_crate(tcx: ty::ctxt,
170170
crate: &Crate) {
171171
let mut visitor = LivenessVisitor;
172172

173-
let initial_maps = @mut IrMaps(tcx,
174-
method_map,
175-
capture_map);
173+
let initial_maps = @IrMaps(tcx, method_map, capture_map);
176174
visit::walk_crate(&mut visitor, crate, initial_maps);
177175
tcx.sess.abort_if_errors();
178176
}
@@ -273,7 +271,7 @@ fn IrMaps(tcx: ty::ctxt,
273271
}
274272

275273
impl IrMaps {
276-
pub fn add_live_node(&mut self, lnk: LiveNodeKind) -> LiveNode {
274+
pub fn add_live_node(&self, lnk: LiveNodeKind) -> LiveNode {
277275
let num_live_nodes = self.num_live_nodes.get();
278276
let ln = LiveNode(num_live_nodes);
279277
let mut lnks = self.lnks.borrow_mut();
@@ -286,17 +284,15 @@ impl IrMaps {
286284
ln
287285
}
288286

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) {
292288
let ln = self.add_live_node(lnk);
293289
let mut live_node_map = self.live_node_map.borrow_mut();
294290
live_node_map.get().insert(node_id, ln);
295291

296292
debug!("{} is node {}", ln.to_str(), node_id);
297293
}
298294

299-
pub fn add_variable(&mut self, vk: VarKind) -> Variable {
295+
pub fn add_variable(&self, vk: VarKind) -> Variable {
300296
let v = Variable(self.num_vars.get());
301297
{
302298
let mut var_kinds = self.var_kinds.borrow_mut();
@@ -317,7 +313,7 @@ impl IrMaps {
317313
v
318314
}
319315

320-
pub fn variable(&mut self, node_id: NodeId, span: Span) -> Variable {
316+
pub fn variable(&self, node_id: NodeId, span: Span) -> Variable {
321317
let variable_map = self.variable_map.borrow();
322318
match variable_map.get().find(&node_id) {
323319
Some(&var) => var,
@@ -328,7 +324,7 @@ impl IrMaps {
328324
}
329325
}
330326

331-
pub fn variable_name(&mut self, var: Variable) -> @str {
327+
pub fn variable_name(&self, var: Variable) -> @str {
332328
let var_kinds = self.var_kinds.borrow();
333329
match var_kinds.get()[*var] {
334330
Local(LocalInfo { ident: nm, .. }) | Arg(_, nm) => {
@@ -338,12 +334,12 @@ impl IrMaps {
338334
}
339335
}
340336
341-
pub fn set_captures(&mut self, node_id: NodeId, cs: ~[CaptureInfo]) {
337+
pub fn set_captures(&self, node_id: NodeId, cs: ~[CaptureInfo]) {
342338
let mut capture_info_map = self.capture_info_map.borrow_mut();
343339
capture_info_map.get().insert(node_id, @cs);
344340
}
345341
346-
pub fn captures(&mut self, expr: &Expr) -> @~[CaptureInfo] {
342+
pub fn captures(&self, expr: &Expr) -> @~[CaptureInfo] {
347343
let capture_info_map = self.capture_info_map.borrow();
348344
match capture_info_map.get().find(&expr.id) {
349345
Some(&caps) => caps,
@@ -353,7 +349,7 @@ impl IrMaps {
353349
}
354350
}
355351

356-
pub fn lnk(&mut self, ln: LiveNode) -> LiveNodeKind {
352+
pub fn lnk(&self, ln: LiveNode) -> LiveNodeKind {
357353
let lnks = self.lnks.borrow();
358354
lnks.get()[*ln]
359355
}
@@ -380,14 +376,12 @@ fn visit_fn(v: &mut LivenessVisitor,
380376
body: P<Block>,
381377
sp: Span,
382378
id: NodeId,
383-
this: @mut IrMaps) {
379+
this: @IrMaps) {
384380
debug!("visit_fn: id={}", id);
385381
let _i = ::util::common::indenter();
386382

387383
// 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);
391385

392386
unsafe {
393387
debug!("creating fn_maps: {}", transmute::<&IrMaps, *IrMaps>(fn_maps));
@@ -441,7 +435,7 @@ fn visit_fn(v: &mut LivenessVisitor,
441435
lsets.warn_about_unused_args(decl, entry_ln);
442436
}
443437

444-
fn visit_local(v: &mut LivenessVisitor, local: @Local, this: @mut IrMaps) {
438+
fn visit_local(v: &mut LivenessVisitor, local: @Local, this: @IrMaps) {
445439
let def_map = this.tcx.def_map;
446440
pat_util::pat_bindings(def_map, local.pat, |bm, p_id, sp, path| {
447441
debug!("adding local variable {}", p_id);
@@ -465,7 +459,7 @@ fn visit_local(v: &mut LivenessVisitor, local: @Local, this: @mut IrMaps) {
465459
visit::walk_local(v, local, this);
466460
}
467461

468-
fn visit_arm(v: &mut LivenessVisitor, arm: &Arm, this: @mut IrMaps) {
462+
fn visit_arm(v: &mut LivenessVisitor, arm: &Arm, this: @IrMaps) {
469463
let def_map = this.tcx.def_map;
470464
for pat in arm.pats.iter() {
471465
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) {
488482
visit::walk_arm(v, arm, this);
489483
}
490484

491-
fn visit_expr(v: &mut LivenessVisitor, expr: @Expr, this: @mut IrMaps) {
485+
fn visit_expr(v: &mut LivenessVisitor, expr: @Expr, this: @IrMaps) {
492486
match expr.node {
493487
// live nodes required for uses or definitions of variables:
494488
ExprPath(_) | ExprSelf => {
@@ -594,7 +588,7 @@ type LiveNodeMap = @RefCell<HashMap<NodeId, LiveNode>>;
594588

595589
pub struct Liveness {
596590
tcx: ty::ctxt,
597-
ir: @mut IrMaps,
591+
ir: @IrMaps,
598592
s: Specials,
599593
successors: @mut ~[LiveNode],
600594
users: @mut ~[Users],
@@ -608,7 +602,7 @@ pub struct Liveness {
608602
cont_ln: LiveNodeMap
609603
}
610604

611-
fn Liveness(ir: @mut IrMaps, specials: Specials) -> Liveness {
605+
fn Liveness(ir: @IrMaps, specials: Specials) -> Liveness {
612606
Liveness {
613607
ir: ir,
614608
tcx: ir.tcx,
@@ -626,7 +620,7 @@ fn Liveness(ir: @mut IrMaps, specials: Specials) -> Liveness {
626620

627621
impl Liveness {
628622
pub fn live_node(&self, node_id: NodeId, span: Span) -> LiveNode {
629-
let ir: &mut IrMaps = self.ir;
623+
let ir: &IrMaps = self.ir;
630624
let live_node_map = ir.live_node_map.borrow();
631625
match live_node_map.get().find(&node_id) {
632626
Some(&ln) => ln,

0 commit comments

Comments
 (0)