aboutsummaryrefslogtreecommitdiff
path: root/src/comp/pretty/pprust.rs
diff options
context:
space:
mode:
authorMarijn Haverbeke <[email protected]>2011-03-09 11:41:50 +0100
committerunknown <graydon@.(none)>2011-03-09 16:15:55 -0800
commitaed40fbcd8e81cc1ef7a51b40b76b4631cba299e (patch)
treeb9fe1cf0f40a6f54ab8b6522a3ed6677b127bb02 /src/comp/pretty/pprust.rs
parentAdd stdout_writer and string_writer to std.io (diff)
downloadrust-aed40fbcd8e81cc1ef7a51b40b76b4631cba299e.tar.xz
rust-aed40fbcd8e81cc1ef7a51b40b76b4631cba299e.zip
Have the pretty-printer take a writer stream as argument
It now uses a string writer to also fill in for middle.ty.ast_ty_to_str
Diffstat (limited to 'src/comp/pretty/pprust.rs')
-rw-r--r--src/comp/pretty/pprust.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/comp/pretty/pprust.rs b/src/comp/pretty/pprust.rs
index c54786fd..e766cacd 100644
--- a/src/comp/pretty/pprust.rs
+++ b/src/comp/pretty/pprust.rs
@@ -11,13 +11,19 @@ import foo = std.io;
const uint indent_unit = 2u;
const int as_prec = 5;
-impure fn print_ast(ast._mod _mod) {
- auto s = pp.mkstate(80u);
+impure fn print_ast(ast._mod _mod, std.io.writer out) {
+ auto s = pp.mkstate(out, 80u);
for (@ast.view_item vitem in _mod.view_items) {print_view_item(s, vitem);}
line(s);
for (@ast.item item in _mod.items) {print_item(s, item);}
}
+fn ty_to_str(&@ast.ty ty) -> str {
+ auto writer = std.io.string_writer();
+ print_type(pp.mkstate(writer.get_writer(), 0u), ty);
+ ret writer.get_str();
+}
+
impure fn hbox(ps s) {
pp.hbox(s, indent_unit);
}