@@ -69,10 +69,18 @@ pub fn compile_input(sess: Session,
69
69
let ( outputs, expanded_crate, id) = {
70
70
let krate = phase_1_parse_input ( & sess, cfg, input) ;
71
71
72
+ let krate = if control. every_body_loops {
73
+ use syntax:: fold:: Folder ;
74
+ :: pretty:: ReplaceBodyWithLoop :: new ( ) . fold_crate ( krate)
75
+ } else {
76
+ krate
77
+ } ;
78
+
72
79
controller_entry_point ! ( after_parse,
73
80
CompileState :: state_after_parse( input,
74
81
& sess,
75
82
outdir,
83
+ output,
76
84
& krate) ) ;
77
85
78
86
let outputs = build_output_filenames ( input,
@@ -99,6 +107,7 @@ pub fn compile_input(sess: Session,
99
107
CompileState :: state_after_expand( input,
100
108
& sess,
101
109
outdir,
110
+ output,
102
111
& expanded_crate,
103
112
& id[ ..] ) ) ;
104
113
@@ -112,6 +121,7 @@ pub fn compile_input(sess: Session,
112
121
CompileState :: state_after_write_deps( input,
113
122
& sess,
114
123
outdir,
124
+ output,
115
125
& ast_map,
116
126
& ast_map. krate( ) ,
117
127
& id[ ..] ) ) ;
@@ -126,6 +136,7 @@ pub fn compile_input(sess: Session,
126
136
CompileState :: state_after_analysis( input,
127
137
& analysis. ty_cx. sess,
128
138
outdir,
139
+ output,
129
140
analysis. ty_cx. map. krate( ) ,
130
141
& analysis,
131
142
& analysis. ty_cx) ) ;
@@ -152,6 +163,7 @@ pub fn compile_input(sess: Session,
152
163
CompileState :: state_after_llvm( input,
153
164
& sess,
154
165
outdir,
166
+ output,
155
167
& trans) ) ;
156
168
157
169
phase_6_link_output ( & sess, & trans, & outputs) ;
@@ -193,6 +205,7 @@ pub struct CompileController<'a> {
193
205
pub after_llvm : PhaseController < ' a > ,
194
206
195
207
pub make_glob_map : resolve:: MakeGlobMap ,
208
+ pub every_body_loops : bool ,
196
209
}
197
210
198
211
impl < ' a > CompileController < ' a > {
@@ -204,6 +217,7 @@ impl<'a> CompileController<'a> {
204
217
after_analysis : PhaseController :: basic ( ) ,
205
218
after_llvm : PhaseController :: basic ( ) ,
206
219
make_glob_map : resolve:: MakeGlobMap :: No ,
220
+ every_body_loops : false ,
207
221
}
208
222
}
209
223
}
@@ -225,30 +239,33 @@ impl<'a> PhaseController<'a> {
225
239
/// State that is passed to a callback. What state is available depends on when
226
240
/// during compilation the callback is made. See the various constructor methods
227
241
/// (`state_*`) in the impl to see which data is provided for any given entry point.
228
- pub struct CompileState < ' a , ' ast : ' a , ' tcx : ' a > {
242
+ pub struct CompileState < ' a , ' tcx : ' a > {
229
243
pub input : & ' a Input ,
230
244
pub session : & ' a Session ,
231
245
pub cfg : Option < & ' a ast:: CrateConfig > ,
232
246
pub krate : Option < & ' a ast:: Crate > ,
233
247
pub crate_name : Option < & ' a str > ,
234
248
pub output_filenames : Option < & ' a OutputFilenames > ,
235
249
pub out_dir : Option < & ' a Path > ,
250
+ pub output : Option < & ' a Path > ,
236
251
pub expanded_crate : Option < & ' a ast:: Crate > ,
237
- pub ast_map : Option < & ' a ast_map:: Map < ' ast > > ,
252
+ pub ast_map : Option < & ' a ast_map:: Map < ' tcx > > ,
238
253
pub analysis : Option < & ' a ty:: CrateAnalysis < ' tcx > > ,
239
254
pub tcx : Option < & ' a ty:: ctxt < ' tcx > > ,
240
255
pub trans : Option < & ' a trans:: CrateTranslation > ,
241
256
}
242
257
243
- impl < ' a , ' ast , ' tcx > CompileState < ' a , ' ast , ' tcx > {
258
+ impl < ' a , ' tcx > CompileState < ' a , ' tcx > {
244
259
fn empty ( input : & ' a Input ,
245
260
session : & ' a Session ,
246
- out_dir : & ' a Option < Path > )
247
- -> CompileState < ' a , ' ast , ' tcx > {
261
+ out_dir : & ' a Option < Path > ,
262
+ output : & ' a Option < Path > )
263
+ -> CompileState < ' a , ' tcx > {
248
264
CompileState {
249
265
input : input,
250
266
session : session,
251
267
out_dir : out_dir. as_ref ( ) ,
268
+ output : output. as_ref ( ) ,
252
269
cfg : None ,
253
270
krate : None ,
254
271
crate_name : None ,
@@ -264,66 +281,71 @@ impl<'a, 'ast, 'tcx> CompileState<'a, 'ast, 'tcx> {
264
281
fn state_after_parse ( input : & ' a Input ,
265
282
session : & ' a Session ,
266
283
out_dir : & ' a Option < Path > ,
284
+ output : & ' a Option < Path > ,
267
285
krate : & ' a ast:: Crate )
268
- -> CompileState < ' a , ' ast , ' tcx > {
286
+ -> CompileState < ' a , ' tcx > {
269
287
CompileState {
270
288
krate : Some ( krate) ,
271
- .. CompileState :: empty ( input, session, out_dir)
289
+ .. CompileState :: empty ( input, session, out_dir, output )
272
290
}
273
291
}
274
292
275
293
fn state_after_expand ( input : & ' a Input ,
276
294
session : & ' a Session ,
277
295
out_dir : & ' a Option < Path > ,
296
+ output : & ' a Option < Path > ,
278
297
expanded_crate : & ' a ast:: Crate ,
279
298
crate_name : & ' a str )
280
- -> CompileState < ' a , ' ast , ' tcx > {
299
+ -> CompileState < ' a , ' tcx > {
281
300
CompileState {
282
301
crate_name : Some ( crate_name) ,
283
302
expanded_crate : Some ( expanded_crate) ,
284
- .. CompileState :: empty ( input, session, out_dir)
303
+ .. CompileState :: empty ( input, session, out_dir, output )
285
304
}
286
305
}
287
306
288
307
fn state_after_write_deps ( input : & ' a Input ,
289
308
session : & ' a Session ,
290
309
out_dir : & ' a Option < Path > ,
291
- ast_map : & ' a ast_map:: Map < ' ast > ,
310
+ output : & ' a Option < Path > ,
311
+ ast_map : & ' a ast_map:: Map < ' tcx > ,
292
312
expanded_crate : & ' a ast:: Crate ,
293
313
crate_name : & ' a str )
294
- -> CompileState < ' a , ' ast , ' tcx > {
314
+ -> CompileState < ' a , ' tcx > {
295
315
CompileState {
296
316
crate_name : Some ( crate_name) ,
297
317
ast_map : Some ( ast_map) ,
298
318
expanded_crate : Some ( expanded_crate) ,
299
- .. CompileState :: empty ( input, session, out_dir)
319
+ .. CompileState :: empty ( input, session, out_dir, output )
300
320
}
301
321
}
302
322
303
323
fn state_after_analysis ( input : & ' a Input ,
304
324
session : & ' a Session ,
305
325
out_dir : & ' a Option < Path > ,
326
+ output : & ' a Option < Path > ,
306
327
expanded_crate : & ' a ast:: Crate ,
307
328
analysis : & ' a ty:: CrateAnalysis < ' tcx > ,
308
329
tcx : & ' a ty:: ctxt < ' tcx > )
309
- -> CompileState < ' a , ' ast , ' tcx > {
330
+ -> CompileState < ' a , ' tcx > {
310
331
CompileState {
311
332
analysis : Some ( analysis) ,
312
333
tcx : Some ( tcx) ,
313
334
expanded_crate : Some ( expanded_crate) ,
314
- .. CompileState :: empty ( input, session, out_dir)
335
+ .. CompileState :: empty ( input, session, out_dir, output )
315
336
}
316
337
}
317
338
318
339
319
340
fn state_after_llvm ( input : & ' a Input ,
320
341
session : & ' a Session ,
321
342
out_dir : & ' a Option < Path > ,
343
+ output : & ' a Option < Path > ,
322
344
trans : & ' a trans:: CrateTranslation )
323
- -> CompileState < ' a , ' ast , ' tcx > {
345
+ -> CompileState < ' a , ' tcx > {
324
346
CompileState {
325
347
trans : Some ( trans) ,
326
- .. CompileState :: empty ( input, session, out_dir)
348
+ .. CompileState :: empty ( input, session, out_dir, output )
327
349
}
328
350
}
329
351
}
0 commit comments