add pretty print

This commit is contained in:
nora 2022-01-04 23:09:18 +01:00
parent 1a77e710d5
commit 76af14a9f4
11 changed files with 114 additions and 5 deletions

View file

@ -63,7 +63,14 @@ fn process_ast(program: &str, ast: &Program, mut runtime: RtAlloc, cfg: &mut Con
match bytecode {
Ok(code) => {
if cfg.debug {
println!("Bytecode:\n{:#?}\n", code);
#[cfg(feature = "pretty")]
{
println!("Bytecode:\n{}\n", debug2::pprint(code));
}
#[cfg(not(feature = "pretty"))]
{
println!("Bytecode:\n{:#?}\n", code);
}
}
let result = vm::execute(&code, runtime, cfg.stdout);