librustc: De-@mut
all writers
This commit is contained in:
parent
b26018cc89
commit
497b63ddf0
4 changed files with 38 additions and 17 deletions
|
@ -600,7 +600,7 @@ pub fn pretty_print_input(sess: Session,
|
||||||
&crate,
|
&crate,
|
||||||
source_name(input),
|
source_name(input),
|
||||||
rdr as @mut io::Reader,
|
rdr as @mut io::Reader,
|
||||||
@mut stdout as @mut io::Writer,
|
~stdout as ~io::Writer,
|
||||||
annotation,
|
annotation,
|
||||||
is_expanded);
|
is_expanded);
|
||||||
}
|
}
|
||||||
|
|
|
@ -347,12 +347,12 @@ impl<O:DataFlowOperator+Clone+'static> DataFlowContext<O> {
|
||||||
debug!("Dataflow result:");
|
debug!("Dataflow result:");
|
||||||
debug!("{}", {
|
debug!("{}", {
|
||||||
let this = @(*self).clone();
|
let this = @(*self).clone();
|
||||||
this.pretty_print_to(@mut io::stderr() as @mut io::Writer, blk);
|
this.pretty_print_to(~io::stderr() as ~io::Writer, blk);
|
||||||
""
|
""
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pretty_print_to(@self, wr: @mut io::Writer, blk: &ast::Block) {
|
fn pretty_print_to(@self, wr: ~io::Writer, blk: &ast::Block) {
|
||||||
let mut ps = pprust::rust_printer_annotated(wr,
|
let mut ps = pprust::rust_printer_annotated(wr,
|
||||||
self.tcx.sess.intr(),
|
self.tcx.sess.intr(),
|
||||||
self as @pprust::pp_ann);
|
self as @pprust::pp_ann);
|
||||||
|
|
|
@ -148,7 +148,7 @@ pub struct print_stack_elt {
|
||||||
|
|
||||||
pub static size_infinity: int = 0xffff;
|
pub static size_infinity: int = 0xffff;
|
||||||
|
|
||||||
pub fn mk_printer(out: @mut io::Writer, linewidth: uint) -> Printer {
|
pub fn mk_printer(out: ~io::Writer, linewidth: uint) -> Printer {
|
||||||
// Yes 3, it makes the ring buffers big enough to never
|
// Yes 3, it makes the ring buffers big enough to never
|
||||||
// fall behind.
|
// fall behind.
|
||||||
let n: uint = 3 * linewidth;
|
let n: uint = 3 * linewidth;
|
||||||
|
@ -255,7 +255,7 @@ pub fn mk_printer(out: @mut io::Writer, linewidth: uint) -> Printer {
|
||||||
* called 'print'.
|
* called 'print'.
|
||||||
*/
|
*/
|
||||||
pub struct Printer {
|
pub struct Printer {
|
||||||
out: @mut io::Writer,
|
out: ~io::Writer,
|
||||||
buf_len: uint,
|
buf_len: uint,
|
||||||
margin: int, // width of lines we're constrained to
|
margin: int, // width of lines we're constrained to
|
||||||
space: int, // number of spaces left on line
|
space: int, // number of spaces left on line
|
||||||
|
|
|
@ -27,6 +27,7 @@ use print::pp::{breaks, consistent, inconsistent, eof};
|
||||||
use print::pp;
|
use print::pp;
|
||||||
use print::pprust;
|
use print::pprust;
|
||||||
|
|
||||||
|
use std::cast;
|
||||||
use std::char;
|
use std::char;
|
||||||
use std::str;
|
use std::str;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
@ -86,11 +87,11 @@ pub fn end(s: &mut ps) {
|
||||||
pp::end(&mut s.s);
|
pp::end(&mut s.s);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn rust_printer(writer: @mut io::Writer, intr: @ident_interner) -> ps {
|
pub fn rust_printer(writer: ~io::Writer, intr: @ident_interner) -> ps {
|
||||||
return rust_printer_annotated(writer, intr, @no_ann::new() as @pp_ann);
|
return rust_printer_annotated(writer, intr, @no_ann::new() as @pp_ann);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn rust_printer_annotated(writer: @mut io::Writer,
|
pub fn rust_printer_annotated(writer: ~io::Writer,
|
||||||
intr: @ident_interner,
|
intr: @ident_interner,
|
||||||
ann: @pp_ann)
|
ann: @pp_ann)
|
||||||
-> ps {
|
-> ps {
|
||||||
|
@ -122,7 +123,7 @@ pub fn print_crate(cm: @CodeMap,
|
||||||
crate: &ast::Crate,
|
crate: &ast::Crate,
|
||||||
filename: @str,
|
filename: @str,
|
||||||
input: @mut io::Reader,
|
input: @mut io::Reader,
|
||||||
out: @mut io::Writer,
|
out: ~io::Writer,
|
||||||
ann: @pp_ann,
|
ann: @pp_ann,
|
||||||
is_expanded: bool) {
|
is_expanded: bool) {
|
||||||
let (cmnts, lits) = comments::gather_comments_and_literals(
|
let (cmnts, lits) = comments::gather_comments_and_literals(
|
||||||
|
@ -203,26 +204,40 @@ pub fn path_to_str(p: &ast::Path, intr: @ident_interner) -> ~str {
|
||||||
pub fn fun_to_str(decl: &ast::fn_decl, purity: ast::purity, name: ast::Ident,
|
pub fn fun_to_str(decl: &ast::fn_decl, purity: ast::purity, name: ast::Ident,
|
||||||
opt_explicit_self: Option<ast::explicit_self_>,
|
opt_explicit_self: Option<ast::explicit_self_>,
|
||||||
generics: &ast::Generics, intr: @ident_interner) -> ~str {
|
generics: &ast::Generics, intr: @ident_interner) -> ~str {
|
||||||
let wr = @mut MemWriter::new();
|
let wr = ~MemWriter::new();
|
||||||
let mut s = rust_printer(wr as @mut io::Writer, intr);
|
let mut s = rust_printer(wr as ~io::Writer, intr);
|
||||||
print_fn(&mut s, decl, Some(purity), AbiSet::Rust(),
|
print_fn(&mut s, decl, Some(purity), AbiSet::Rust(),
|
||||||
name, generics, opt_explicit_self, ast::inherited);
|
name, generics, opt_explicit_self, ast::inherited);
|
||||||
end(&mut s); // Close the head box
|
end(&mut s); // Close the head box
|
||||||
end(&mut s); // Close the outer box
|
end(&mut s); // Close the outer box
|
||||||
eof(&mut s.s);
|
eof(&mut s.s);
|
||||||
str::from_utf8_owned(wr.inner_ref().to_owned())
|
|
||||||
|
// XXX(pcwalton): Need checked downcasts.
|
||||||
|
unsafe {
|
||||||
|
let (_, wr): (uint, ~MemWriter) = cast::transmute(s.s.out);
|
||||||
|
let result = str::from_utf8_owned(wr.inner_ref().to_owned());
|
||||||
|
cast::forget(wr);
|
||||||
|
result
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn block_to_str(blk: &ast::Block, intr: @ident_interner) -> ~str {
|
pub fn block_to_str(blk: &ast::Block, intr: @ident_interner) -> ~str {
|
||||||
let wr = @mut MemWriter::new();
|
let wr = ~MemWriter::new();
|
||||||
let mut s = rust_printer(wr as @mut io::Writer, intr);
|
let mut s = rust_printer(wr as ~io::Writer, intr);
|
||||||
// containing cbox, will be closed by print-block at }
|
// containing cbox, will be closed by print-block at }
|
||||||
cbox(&mut s, indent_unit);
|
cbox(&mut s, indent_unit);
|
||||||
// head-ibox, will be closed by print-block after {
|
// head-ibox, will be closed by print-block after {
|
||||||
ibox(&mut s, 0u);
|
ibox(&mut s, 0u);
|
||||||
print_block(&mut s, blk);
|
print_block(&mut s, blk);
|
||||||
eof(&mut s.s);
|
eof(&mut s.s);
|
||||||
str::from_utf8_owned(wr.inner_ref().to_owned())
|
|
||||||
|
// XXX(pcwalton): Need checked downcasts.
|
||||||
|
unsafe {
|
||||||
|
let (_, wr): (uint, ~MemWriter) = cast::transmute(s.s.out);
|
||||||
|
let result = str::from_utf8_owned(wr.inner_ref().to_owned());
|
||||||
|
cast::forget(wr);
|
||||||
|
result
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn meta_item_to_str(mi: &ast::MetaItem, intr: @ident_interner) -> ~str {
|
pub fn meta_item_to_str(mi: &ast::MetaItem, intr: @ident_interner) -> ~str {
|
||||||
|
@ -2304,11 +2319,17 @@ pub fn print_string(s: &mut ps, st: &str, style: ast::StrStyle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_str<T>(t: &T, f: |&mut ps, &T|, intr: @ident_interner) -> ~str {
|
pub fn to_str<T>(t: &T, f: |&mut ps, &T|, intr: @ident_interner) -> ~str {
|
||||||
let wr = @mut MemWriter::new();
|
let wr = ~MemWriter::new();
|
||||||
let mut s = rust_printer(wr as @mut io::Writer, intr);
|
let mut s = rust_printer(wr as ~io::Writer, intr);
|
||||||
f(&mut s, t);
|
f(&mut s, t);
|
||||||
eof(&mut s.s);
|
eof(&mut s.s);
|
||||||
str::from_utf8_owned(wr.inner_ref().to_owned())
|
// XXX(pcwalton): Need checked downcasts.
|
||||||
|
unsafe {
|
||||||
|
let (_, wr): (uint, ~MemWriter) = cast::transmute(s.s.out);
|
||||||
|
let result = str::from_utf8_owned(wr.inner_ref().to_owned());
|
||||||
|
cast::forget(wr);
|
||||||
|
result
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn next_comment(s: &mut ps) -> Option<comments::cmnt> {
|
pub fn next_comment(s: &mut ps) -> Option<comments::cmnt> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue