diff options
| author | Brian Anderson <[email protected]> | 2011-03-31 20:29:59 -0400 |
|---|---|---|
| committer | Brian Anderson <[email protected]> | 2011-03-31 23:15:11 -0400 |
| commit | d631f29d47578c46bfc01e1a8cc021b295866e0c (patch) | |
| tree | 5c219e2ce30fecadf033d6c710bc32ba1f58e7dd /src/comp | |
| parent | Add a test for block expressions that have results. XFAILed. (diff) | |
| download | rust-d631f29d47578c46bfc01e1a8cc021b295866e0c.tar.xz rust-d631f29d47578c46bfc01e1a8cc021b295866e0c.zip | |
Add block_to_str and expr_to_str methods to the pprust module.
Since pprust is authed impure these can be used for debug logging.
Diffstat (limited to 'src/comp')
| -rw-r--r-- | src/comp/pretty/pprust.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/comp/pretty/pprust.rs b/src/comp/pretty/pprust.rs index d478227c..f3b0f3fe 100644 --- a/src/comp/pretty/pprust.rs +++ b/src/comp/pretty/pprust.rs @@ -32,6 +32,24 @@ fn ty_to_str(&@ast.ty ty) -> str { ret writer.get_str(); } +fn block_to_str(&ast.block blk) -> str { + auto writer = io.string_writer(); + auto s = @rec(s=pp.mkstate(writer.get_writer(), 78u), + comments=option.none[vec[lexer.cmnt]], + mutable cur_cmnt=0u); + print_block(s, blk); + ret writer.get_str(); +} + +fn expr_to_str(&@ast.expr e) -> str { + auto writer = io.string_writer(); + auto s = @rec(s=pp.mkstate(writer.get_writer(), 78u), + comments=option.none[vec[lexer.cmnt]], + mutable cur_cmnt=0u); + print_expr(s, e); + ret writer.get_str(); +} + impure fn hbox(ps s) { pp.hbox(s.s, indent_unit); } |