Skip to content

Commit cea2a8a

Browse files
committed
adjust lifetimes and bindings to the GlobalEvalContext -> EvalContext rename
1 parent 9c8f84c commit cea2a8a

File tree

3 files changed

+48
-48
lines changed

3 files changed

+48
-48
lines changed

src/bin/miri.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,17 @@ fn interpret_start_points<'a, 'tcx>(
5959

6060
debug!("Interpreting: {}", item.name);
6161

62-
let mut gecx = EvalContext::new(tcx, mir_map);
62+
let mut ecx = EvalContext::new(tcx, mir_map);
6363
let substs = tcx.mk_substs(subst::Substs::empty());
64-
let return_ptr = gecx.alloc_ret_ptr(mir.return_ty, substs);
64+
let return_ptr = ecx.alloc_ret_ptr(mir.return_ty, substs);
6565

66-
gecx.push_stack_frame(tcx.map.local_def_id(id), mir.span, CachedMir::Ref(mir), substs, return_ptr);
66+
ecx.push_stack_frame(tcx.map.local_def_id(id), mir.span, CachedMir::Ref(mir), substs, return_ptr);
6767

6868
loop {
69-
match (step(&mut gecx), return_ptr) {
69+
match (step(&mut ecx), return_ptr) {
7070
(Ok(true), _) => {},
7171
(Ok(false), Some(ptr)) => if log_enabled!(::log::LogLevel::Debug) {
72-
gecx.memory().dump(ptr.alloc_id);
72+
ecx.memory().dump(ptr.alloc_id);
7373
break;
7474
},
7575
(Ok(false), None) => {
@@ -78,7 +78,7 @@ fn interpret_start_points<'a, 'tcx>(
7878
},
7979
// FIXME: diverging functions can end up here in some future miri
8080
(Err(e), _) => {
81-
report(tcx, &gecx, e);
81+
report(tcx, &ecx, e);
8282
break;
8383
},
8484
}
@@ -88,16 +88,16 @@ fn interpret_start_points<'a, 'tcx>(
8888
}
8989
}
9090

91-
fn report(tcx: TyCtxt, gecx: &EvalContext, e: EvalError) {
92-
let frame = gecx.stack().last().expect("stackframe was empty");
91+
fn report(tcx: TyCtxt, ecx: &EvalContext, e: EvalError) {
92+
let frame = ecx.stack().last().expect("stackframe was empty");
9393
let block = frame.mir.basic_block_data(frame.next_block);
9494
let span = if frame.stmt < block.statements.len() {
9595
block.statements[frame.stmt].span
9696
} else {
9797
block.terminator().span
9898
};
9999
let mut err = tcx.sess.struct_span_err(span, &e.to_string());
100-
for &Frame { def_id, substs, span, .. } in gecx.stack().iter().rev() {
100+
for &Frame { def_id, substs, span, .. } in ecx.stack().iter().rev() {
101101
// FIXME(solson): Find a way to do this without this Display impl hack.
102102
use rustc::util::ppaux;
103103
use std::fmt;

src/interpreter/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ use std::collections::HashMap;
2424

2525
mod stepper;
2626

27-
pub fn step<'fncx, 'a: 'fncx, 'tcx: 'a>(gecx: &'fncx mut EvalContext<'a, 'tcx>) -> EvalResult<bool> {
28-
stepper::Stepper::new(gecx).step()
27+
pub fn step<'ecx, 'a: 'ecx, 'tcx: 'a>(ecx: &'ecx mut EvalContext<'a, 'tcx>) -> EvalResult<bool> {
28+
stepper::Stepper::new(ecx).step()
2929
}
3030

3131
pub struct EvalContext<'a, 'tcx: 'a> {

src/interpreter/stepper.rs

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -12,57 +12,57 @@ use rustc::mir::visit::{Visitor, LvalueContext};
1212
use syntax::codemap::Span;
1313
use std::rc::Rc;
1414

15-
pub(super) struct Stepper<'fncx, 'a: 'fncx, 'tcx: 'a>{
16-
gecx: &'fncx mut EvalContext<'a, 'tcx>,
15+
pub(super) struct Stepper<'ecx, 'a: 'ecx, 'tcx: 'a>{
16+
ecx: &'ecx mut EvalContext<'a, 'tcx>,
1717
}
1818

19-
impl<'fncx, 'a, 'tcx> Stepper<'fncx, 'a, 'tcx> {
20-
pub(super) fn new(gecx: &'fncx mut EvalContext<'a, 'tcx>) -> Self {
19+
impl<'ecx, 'a, 'tcx> Stepper<'ecx, 'a, 'tcx> {
20+
pub(super) fn new(ecx: &'ecx mut EvalContext<'a, 'tcx>) -> Self {
2121
Stepper {
22-
gecx: gecx,
22+
ecx: ecx,
2323
}
2424
}
2525

2626
fn statement(&mut self, stmt: &mir::Statement<'tcx>) -> EvalResult<()> {
2727
trace!("{:?}", stmt);
2828
let mir::StatementKind::Assign(ref lvalue, ref rvalue) = stmt.kind;
29-
self.gecx.eval_assignment(lvalue, rvalue)?;
30-
self.gecx.frame_mut().stmt += 1;
29+
self.ecx.eval_assignment(lvalue, rvalue)?;
30+
self.ecx.frame_mut().stmt += 1;
3131
Ok(())
3232
}
3333

3434
fn terminator(&mut self, terminator: &mir::Terminator<'tcx>) -> EvalResult<()> {
3535
// after a terminator we go to a new block
36-
self.gecx.frame_mut().stmt = 0;
36+
self.ecx.frame_mut().stmt = 0;
3737
trace!("{:?}", terminator.kind);
38-
self.gecx.eval_terminator(terminator)?;
39-
if !self.gecx.stack.is_empty() {
40-
trace!("// {:?}", self.gecx.frame().next_block);
38+
self.ecx.eval_terminator(terminator)?;
39+
if !self.ecx.stack.is_empty() {
40+
trace!("// {:?}", self.ecx.frame().next_block);
4141
}
4242
Ok(())
4343
}
4444

4545
// returns true as long as there are more things to do
4646
pub(super) fn step(&mut self) -> EvalResult<bool> {
47-
if self.gecx.stack.is_empty() {
47+
if self.ecx.stack.is_empty() {
4848
return Ok(false);
4949
}
5050

51-
let block = self.gecx.frame().next_block;
52-
let stmt = self.gecx.frame().stmt;
53-
let mir = self.gecx.mir();
51+
let block = self.ecx.frame().next_block;
52+
let stmt = self.ecx.frame().stmt;
53+
let mir = self.ecx.mir();
5454
let basic_block = mir.basic_block_data(block);
5555

5656
if let Some(ref stmt) = basic_block.statements.get(stmt) {
57-
let current_stack = self.gecx.stack.len();
57+
let current_stack = self.ecx.stack.len();
5858
ConstantExtractor {
5959
span: stmt.span,
60-
substs: self.gecx.substs(),
61-
def_id: self.gecx.frame().def_id,
62-
gecx: self.gecx,
60+
substs: self.ecx.substs(),
61+
def_id: self.ecx.frame().def_id,
62+
ecx: self.ecx,
6363
mir: &mir,
6464
}.visit_statement(block, stmt);
65-
if current_stack == self.gecx.stack.len() {
65+
if current_stack == self.ecx.stack.len() {
6666
self.statement(stmt)?;
6767
} else {
6868
// ConstantExtractor added some new frames for statics/constants/promoteds
@@ -73,15 +73,15 @@ impl<'fncx, 'a, 'tcx> Stepper<'fncx, 'a, 'tcx> {
7373
}
7474

7575
let terminator = basic_block.terminator();
76-
let current_stack = self.gecx.stack.len();
76+
let current_stack = self.ecx.stack.len();
7777
ConstantExtractor {
7878
span: terminator.span,
79-
substs: self.gecx.substs(),
80-
def_id: self.gecx.frame().def_id,
81-
gecx: self.gecx,
79+
substs: self.ecx.substs(),
80+
def_id: self.ecx.frame().def_id,
81+
ecx: self.ecx,
8282
mir: &mir,
8383
}.visit_terminator(block, terminator);
84-
if current_stack == self.gecx.stack.len() {
84+
if current_stack == self.ecx.stack.len() {
8585
self.terminator(terminator)?;
8686
} else {
8787
// ConstantExtractor added some new frames for statics/constants/promoteds
@@ -92,13 +92,13 @@ impl<'fncx, 'a, 'tcx> Stepper<'fncx, 'a, 'tcx> {
9292
}
9393
}
9494

95-
// WARNING: make sure that any methods implemented on this type don't ever access gecx.stack
95+
// WARNING: make sure that any methods implemented on this type don't ever access ecx.stack
9696
// this includes any method that might access the stack
9797
// basically don't call anything other than `load_mir`, `alloc_ret_ptr`, `push_stack_frame`
9898
// The reason for this is, that `push_stack_frame` modifies the stack out of obvious reasons
9999
struct ConstantExtractor<'a, 'b: 'a, 'tcx: 'b> {
100100
span: Span,
101-
gecx: &'a mut EvalContext<'b, 'tcx>,
101+
ecx: &'a mut EvalContext<'b, 'tcx>,
102102
mir: &'a mir::Mir<'tcx>,
103103
def_id: DefId,
104104
substs: &'tcx subst::Substs<'tcx>,
@@ -111,13 +111,13 @@ impl<'a, 'b, 'tcx> ConstantExtractor<'a, 'b, 'tcx> {
111111
substs: substs,
112112
kind: ConstantKind::Global,
113113
};
114-
if self.gecx.statics.contains_key(&cid) {
114+
if self.ecx.statics.contains_key(&cid) {
115115
return;
116116
}
117-
let mir = self.gecx.load_mir(def_id);
118-
let ptr = self.gecx.alloc_ret_ptr(mir.return_ty, substs).expect("there's no such thing as an unreachable static");
119-
self.gecx.statics.insert(cid.clone(), ptr);
120-
self.gecx.push_stack_frame(def_id, span, mir, substs, Some(ptr));
117+
let mir = self.ecx.load_mir(def_id);
118+
let ptr = self.ecx.alloc_ret_ptr(mir.return_ty, substs).expect("there's no such thing as an unreachable static");
119+
self.ecx.statics.insert(cid.clone(), ptr);
120+
self.ecx.push_stack_frame(def_id, span, mir, substs, Some(ptr));
121121
}
122122
}
123123

@@ -142,23 +142,23 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for ConstantExtractor<'a, 'b, 'tcx> {
142142
substs: self.substs,
143143
kind: ConstantKind::Promoted(index),
144144
};
145-
if self.gecx.statics.contains_key(&cid) {
145+
if self.ecx.statics.contains_key(&cid) {
146146
return;
147147
}
148148
let mir = self.mir.promoted[index].clone();
149149
let return_ty = mir.return_ty;
150-
let return_ptr = self.gecx.alloc_ret_ptr(return_ty, cid.substs).expect("there's no such thing as an unreachable static");
150+
let return_ptr = self.ecx.alloc_ret_ptr(return_ty, cid.substs).expect("there's no such thing as an unreachable static");
151151
let mir = CachedMir::Owned(Rc::new(mir));
152-
self.gecx.statics.insert(cid.clone(), return_ptr);
153-
self.gecx.push_stack_frame(self.def_id, constant.span, mir, self.substs, Some(return_ptr));
152+
self.ecx.statics.insert(cid.clone(), return_ptr);
153+
self.ecx.push_stack_frame(self.def_id, constant.span, mir, self.substs, Some(return_ptr));
154154
}
155155
}
156156
}
157157

158158
fn visit_lvalue(&mut self, lvalue: &mir::Lvalue<'tcx>, context: LvalueContext) {
159159
self.super_lvalue(lvalue, context);
160160
if let mir::Lvalue::Static(def_id) = *lvalue {
161-
let substs = self.gecx.tcx.mk_substs(subst::Substs::empty());
161+
let substs = self.ecx.tcx.mk_substs(subst::Substs::empty());
162162
let span = self.span;
163163
self.global_item(def_id, substs, span);
164164
}

0 commit comments

Comments
 (0)