@@ -20,6 +20,7 @@ use lib::llvm::{ContextRef, ModuleRef};
20
20
use metadata:: common:: LinkMeta ;
21
21
use metadata:: { creader, filesearch} ;
22
22
use metadata:: cstore:: CStore ;
23
+ use metadata:: creader:: Loader ;
23
24
use metadata;
24
25
use middle:: { trans, freevars, kind, ty, typeck, lint, astencode, reachable} ;
25
26
use middle;
@@ -41,6 +42,7 @@ use syntax::attr;
41
42
use syntax:: attr:: { AttrMetaMethods } ;
42
43
use syntax:: codemap;
43
44
use syntax:: diagnostic;
45
+ use syntax:: ext:: base:: CrateLoader ;
44
46
use syntax:: parse;
45
47
use syntax:: parse:: token;
46
48
use syntax:: print:: { pp, pprust} ;
@@ -163,6 +165,7 @@ pub fn phase_1_parse_input(sess: Session, cfg: ast::CrateConfig, input: &input)
163
165
/// standard library and prelude.
164
166
pub fn phase_2_configure_and_expand ( sess : Session ,
165
167
cfg : ast:: CrateConfig ,
168
+ loader : & mut CrateLoader ,
166
169
mut crate : ast:: Crate )
167
170
-> ( ast:: Crate , syntax:: ast_map:: Map ) {
168
171
let time_passes = sess. time_passes ( ) ;
@@ -188,9 +191,14 @@ pub fn phase_2_configure_and_expand(sess: Session,
188
191
crate = time ( time_passes, "configuration 1" , crate , |crate |
189
192
front:: config:: strip_unconfigured_items ( crate ) ) ;
190
193
191
- crate = time ( time_passes, "expansion" , crate , |crate |
192
- syntax:: ext:: expand:: expand_crate ( sess. parse_sess , cfg. clone ( ) ,
193
- crate ) ) ;
194
+ crate = time ( time_passes, "expansion" , crate , |crate | {
195
+ syntax:: ext:: expand:: expand_crate ( sess. parse_sess ,
196
+ loader,
197
+ cfg. clone ( ) ,
198
+ crate )
199
+ } ) ;
200
+ // dump the syntax-time crates
201
+ sess. cstore . reset ( ) ;
194
202
195
203
// strip again, in case expansion added anything with a #[cfg].
196
204
crate = time ( time_passes, "configuration 2" , crate , |crate |
@@ -248,6 +256,11 @@ pub fn phase_3_run_analysis_passes(sess: Session,
248
256
time ( time_passes, "looking for entry point" , ( ) ,
249
257
|_| middle:: entry:: find_entry_point ( sess, crate , ast_map) ) ;
250
258
259
+ sess. macro_registrar_fn . with_mut ( |r| * r =
260
+ time ( time_passes, "looking for macro registrar" , ( ) , |_|
261
+ syntax:: ext:: registrar:: find_macro_registrar (
262
+ sess. span_diagnostic , crate ) ) ) ;
263
+
251
264
let freevars = time ( time_passes, "freevar finding" , ( ) , |_|
252
265
freevars:: annotate_freevars ( def_map, crate ) ) ;
253
266
@@ -491,7 +504,8 @@ pub fn compile_input(sess: Session, cfg: ast::CrateConfig, input: &input,
491
504
let ( expanded_crate, ast_map) = {
492
505
let crate = phase_1_parse_input ( sess, cfg. clone ( ) , input) ;
493
506
if stop_after_phase_1 ( sess) { return ; }
494
- phase_2_configure_and_expand ( sess, cfg, crate )
507
+ let loader = & mut Loader :: new ( sess) ;
508
+ phase_2_configure_and_expand ( sess, cfg, loader, crate )
495
509
} ;
496
510
let outputs = build_output_filenames ( input, outdir, output,
497
511
expanded_crate. attrs , sess) ;
@@ -579,7 +593,8 @@ pub fn pretty_print_input(sess: Session,
579
593
580
594
let ( crate , ast_map, is_expanded) = match ppm {
581
595
PpmExpanded | PpmExpandedIdentified | PpmTyped => {
582
- let ( crate , ast_map) = phase_2_configure_and_expand ( sess, cfg, crate ) ;
596
+ let loader = & mut Loader :: new ( sess) ;
597
+ let ( crate , ast_map) = phase_2_configure_and_expand ( sess, cfg, loader, crate ) ;
583
598
( crate , Some ( ast_map) , true )
584
599
}
585
600
_ => ( crate , None , false )
@@ -912,6 +927,7 @@ pub fn build_session_(sopts: @session::options,
912
927
// For a library crate, this is always none
913
928
entry_fn : RefCell :: new ( None ) ,
914
929
entry_type : Cell :: new ( None ) ,
930
+ macro_registrar_fn : RefCell :: new ( None ) ,
915
931
span_diagnostic : span_diagnostic_handler,
916
932
filesearch : filesearch,
917
933
building_library : Cell :: new ( false ) ,
0 commit comments