diff options
| author | Felix S. Klock II <pnkfelix@pnkfx.org> | 2016-04-28 16:22:27 +0200 |
|---|---|---|
| committer | Felix S. Klock II <pnkfelix@pnkfx.org> | 2016-05-16 09:13:42 +0200 |
| commit | 4446e793dad3bf28c67f1bc70d6380f13de63b49 (patch) | |
| tree | a72d9f93d53cab415f31021c017f4b9ad9b979c6 /src | |
| parent | 90b7a86268036947f0b11a465728ea88a2fb1480 (diff) | |
| download | rust-4446e793dad3bf28c67f1bc70d6380f13de63b49.tar.gz rust-4446e793dad3bf28c67f1bc70d6380f13de63b49.zip | |
Expose pretty print routines that accept just `mir` (no need for a `NodeId`).
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_mir/pretty.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/librustc_mir/pretty.rs b/src/librustc_mir/pretty.rs index a6bbd55ffa7..33f1df17bcb 100644 --- a/src/librustc_mir/pretty.rs +++ b/src/librustc_mir/pretty.rs @@ -269,6 +269,29 @@ fn write_scope_tree(tcx: TyCtxt, Ok(()) } +pub fn write_mir_named(tcx: &ty::TyCtxt, name: &str, mir: &Mir, w: &mut Write, auxiliary: Option<&ScopeAuxiliaryVec>) +-> io::Result<()> { + + let annotations = scope_entry_exit_annotations(auxiliary); + write_mir_intro_named(tcx, name, mir, w)?; + for block in mir.all_basic_blocks() { + write_basic_block(tcx, block, mir, w, &annotations)?; + } + writeln!(w, "}}") +} + +/// Write out a human-readable textual representation of the MIR's +/// `fn` type and the types of its local variables (both user-defined +/// bindings and compiler temporaries). Assumes the function +/// represented by `mir` is named `name`. Note: Generated output +/// introduces an open curly that needs to be closed. +pub fn write_mir_intro_named(tcx: &ty::TyCtxt, name: &str, mir: &Mir, w: &mut Write) +-> io::Result<()> { + write_mir_fn_sig(tcx, name, mir, w)?; + writeln!(w, " {{")?; + write_mir_fn_decls(tcx, mir, w) +} + /// Write out a human-readable textual representation of the MIR's `fn` type and the types of its /// local variables (both user-defined bindings and compiler temporaries). fn write_mir_intro<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, |
