diff options
| author | Paul Stansifer <paul.stansifer@gmail.com> | 2012-07-27 14:21:15 -0700 |
|---|---|---|
| committer | Paul Stansifer <paul.stansifer@gmail.com> | 2012-07-30 18:04:19 -0700 |
| commit | 19922fcd93bfeac123719e319b7166f50660f847 (patch) | |
| tree | 6eab8aa33d8d72ae8bb02fd4c946010737e28e8f /src | |
| parent | 4e9c475527b0a4cbf43b14c028370b0f784fd99f (diff) | |
| download | rust-19922fcd93bfeac123719e319b7166f50660f847.tar.gz rust-19922fcd93bfeac123719e319b7166f50660f847.zip | |
Feed the interner to the pretty-printer, in anticipation of pretty-printing token trees.
Diffstat (limited to 'src')
| -rw-r--r-- | src/fuzzer/fuzzer.rs | 40 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 9 | ||||
| -rw-r--r-- | src/rustc/driver/driver.rs | 3 |
3 files changed, 33 insertions, 19 deletions
diff --git a/src/fuzzer/fuzzer.rs b/src/fuzzer/fuzzer.rs index a75f920cfd8..908dff102f7 100644 --- a/src/fuzzer/fuzzer.rs +++ b/src/fuzzer/fuzzer.rs @@ -263,6 +263,9 @@ fn check_variants_T<T: copy>( let str3 = @as_str(|a|pprust::print_crate( codemap, + // Assuming we're not generating any token_trees + @syntax::util::interner::mk::<@~str>( + |x| str::hash(*x), |x,y| str::eq(*x,*y)), diagnostic::mk_span_handler(handler, codemap), crate2, filename, @@ -420,13 +423,18 @@ fn parse_and_print(code: @~str) -> ~str { let crate = parse::parse_crate_from_source_str( filename, code, ~[], sess); io::with_str_reader(*code, |rdr| { - as_str(|a| pprust::print_crate(sess.cm, - sess.span_diagnostic, - crate, - filename, - rdr, a, - pprust::no_ann(), - false) ) + as_str(|a| + pprust::print_crate( + sess.cm, + // Assuming there are no token_trees + @syntax::util::interner::mk::<@~str>( + |x| str::hash(*x), |x,y| str::eq(*x,*y)), + sess.span_diagnostic, + crate, + filename, + rdr, a, + pprust::no_ann(), + false) ) }) } @@ -565,13 +573,17 @@ fn check_variants(files: ~[~str], cx: context) { s, ~[], sess); io::with_str_reader(*s, |rdr| { #error("%s", - as_str(|a| pprust::print_crate(sess.cm, - sess.span_diagnostic, - crate, - file, - rdr, a, - pprust::no_ann(), - false) )) + as_str(|a| pprust::print_crate( + sess.cm, + // Assuming no token_trees + @syntax::util::interner::mk::<@~str>( + |x| str::hash(*x), |x,y| str::eq(*x,*y)), + sess.span_diagnostic, + crate, + file, + rdr, a, + pprust::no_ann(), + false) )) }); check_variants_of_ast(*crate, sess.cm, file, cx); } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 9adc3b05ac6..3e23d066c75 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -28,7 +28,7 @@ fn no_ann() -> pp_ann { type ps = @{s: pp::printer, cm: option<codemap>, - //in: interner::interner<@~str>, + intr: @interner::interner<@~str>, comments: option<~[comments::cmnt]>, literals: option<~[comments::lit]>, mut cur_cmnt: uint, @@ -49,7 +49,8 @@ fn end(s: ps) { fn rust_printer(writer: io::writer) -> ps { ret @{s: pp::mk_printer(writer, default_columns), cm: none::<codemap>, - //in: interner::mk::<@~str>(|x| str::hash(*x), |x,y| str::eq(*x, *y)), + intr: @interner::mk::<@~str>(|x| str::hash(*x), + |x,y| str::eq(*x, *y)), comments: none::<~[comments::cmnt]>, literals: none::<~[comments::lit]>, mut cur_cmnt: 0u, @@ -66,7 +67,7 @@ const default_columns: uint = 78u; // Requires you to pass an input filename and reader so that // it can scan the input text for comments and literals to // copy forward. -fn print_crate(cm: codemap, //in: interner::interner<@~str>, +fn print_crate(cm: codemap, intr: @interner::interner<@~str>, span_diagnostic: diagnostic::span_handler, crate: @ast::crate, filename: ~str, in: io::reader, out: io::writer, ann: pp_ann, is_expanded: bool) { @@ -75,7 +76,7 @@ fn print_crate(cm: codemap, //in: interner::interner<@~str>, let s = @{s: pp::mk_printer(out, default_columns), cm: some(cm), - //in: in, + intr: intr, comments: some(r.cmnts), // If the code is post expansion, don't use the table of // literals, since it doesn't correspond with the literals diff --git a/src/rustc/driver/driver.rs b/src/rustc/driver/driver.rs index ee0f28c9a0e..e88c92d2110 100644 --- a/src/rustc/driver/driver.rs +++ b/src/rustc/driver/driver.rs @@ -327,7 +327,8 @@ fn pretty_print_input(sess: session, cfg: ast::crate_cfg, input: input, let is_expanded = upto != cu_parse; let src = codemap::get_filemap(sess.codemap, source_name(input)).src; do io::with_str_reader(*src) |rdr| { - pprust::print_crate(sess.codemap, sess.span_diagnostic, crate, + pprust::print_crate(sess.codemap, sess.parse_sess.interner, + sess.span_diagnostic, crate, source_name(input), rdr, io::stdout(), ann, is_expanded); } |
