@@ -12,57 +12,57 @@ use rustc::mir::visit::{Visitor, LvalueContext};
12
12
use syntax:: codemap:: Span ;
13
13
use std:: rc:: Rc ;
14
14
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 > ,
17
17
}
18
18
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 {
21
21
Stepper {
22
- gecx : gecx ,
22
+ ecx : ecx ,
23
23
}
24
24
}
25
25
26
26
fn statement ( & mut self , stmt : & mir:: Statement < ' tcx > ) -> EvalResult < ( ) > {
27
27
trace ! ( "{:?}" , stmt) ;
28
28
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 ;
31
31
Ok ( ( ) )
32
32
}
33
33
34
34
fn terminator ( & mut self , terminator : & mir:: Terminator < ' tcx > ) -> EvalResult < ( ) > {
35
35
// after a terminator we go to a new block
36
- self . gecx . frame_mut ( ) . stmt = 0 ;
36
+ self . ecx . frame_mut ( ) . stmt = 0 ;
37
37
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) ;
41
41
}
42
42
Ok ( ( ) )
43
43
}
44
44
45
45
// returns true as long as there are more things to do
46
46
pub ( super ) fn step ( & mut self ) -> EvalResult < bool > {
47
- if self . gecx . stack . is_empty ( ) {
47
+ if self . ecx . stack . is_empty ( ) {
48
48
return Ok ( false ) ;
49
49
}
50
50
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 ( ) ;
54
54
let basic_block = mir. basic_block_data ( block) ;
55
55
56
56
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 ( ) ;
58
58
ConstantExtractor {
59
59
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 ,
63
63
mir : & mir,
64
64
} . visit_statement ( block, stmt) ;
65
- if current_stack == self . gecx . stack . len ( ) {
65
+ if current_stack == self . ecx . stack . len ( ) {
66
66
self . statement ( stmt) ?;
67
67
} else {
68
68
// ConstantExtractor added some new frames for statics/constants/promoteds
@@ -73,15 +73,15 @@ impl<'fncx, 'a, 'tcx> Stepper<'fncx, 'a, 'tcx> {
73
73
}
74
74
75
75
let terminator = basic_block. terminator ( ) ;
76
- let current_stack = self . gecx . stack . len ( ) ;
76
+ let current_stack = self . ecx . stack . len ( ) ;
77
77
ConstantExtractor {
78
78
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 ,
82
82
mir : & mir,
83
83
} . visit_terminator ( block, terminator) ;
84
- if current_stack == self . gecx . stack . len ( ) {
84
+ if current_stack == self . ecx . stack . len ( ) {
85
85
self . terminator ( terminator) ?;
86
86
} else {
87
87
// ConstantExtractor added some new frames for statics/constants/promoteds
@@ -92,13 +92,13 @@ impl<'fncx, 'a, 'tcx> Stepper<'fncx, 'a, 'tcx> {
92
92
}
93
93
}
94
94
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
96
96
// this includes any method that might access the stack
97
97
// basically don't call anything other than `load_mir`, `alloc_ret_ptr`, `push_stack_frame`
98
98
// The reason for this is, that `push_stack_frame` modifies the stack out of obvious reasons
99
99
struct ConstantExtractor < ' a , ' b : ' a , ' tcx : ' b > {
100
100
span : Span ,
101
- gecx : & ' a mut EvalContext < ' b , ' tcx > ,
101
+ ecx : & ' a mut EvalContext < ' b , ' tcx > ,
102
102
mir : & ' a mir:: Mir < ' tcx > ,
103
103
def_id : DefId ,
104
104
substs : & ' tcx subst:: Substs < ' tcx > ,
@@ -111,13 +111,13 @@ impl<'a, 'b, 'tcx> ConstantExtractor<'a, 'b, 'tcx> {
111
111
substs : substs,
112
112
kind : ConstantKind :: Global ,
113
113
} ;
114
- if self . gecx . statics . contains_key ( & cid) {
114
+ if self . ecx . statics . contains_key ( & cid) {
115
115
return ;
116
116
}
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) ) ;
121
121
}
122
122
}
123
123
@@ -142,23 +142,23 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for ConstantExtractor<'a, 'b, 'tcx> {
142
142
substs : self . substs ,
143
143
kind : ConstantKind :: Promoted ( index) ,
144
144
} ;
145
- if self . gecx . statics . contains_key ( & cid) {
145
+ if self . ecx . statics . contains_key ( & cid) {
146
146
return ;
147
147
}
148
148
let mir = self . mir . promoted [ index] . clone ( ) ;
149
149
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" ) ;
151
151
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) ) ;
154
154
}
155
155
}
156
156
}
157
157
158
158
fn visit_lvalue ( & mut self , lvalue : & mir:: Lvalue < ' tcx > , context : LvalueContext ) {
159
159
self . super_lvalue ( lvalue, context) ;
160
160
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 ( ) ) ;
162
162
let span = self . span ;
163
163
self . global_item ( def_id, substs, span) ;
164
164
}
0 commit comments