From aed40fbcd8e81cc1ef7a51b40b76b4631cba299e Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 9 Mar 2011 11:41:50 +0100 Subject: 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 --- src/comp/pretty/pprust.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/comp/pretty/pprust.rs') 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); } -- cgit v1.2.3