Skip to content

Commit

Permalink
[move-prover][spec-flatten] add an option to use ExpDisplay for debug
Browse files Browse the repository at this point in the history
The pretty printer intentionally omitted some information (e.g., type
parameters or type arguments), which are captured in `ExpDisplay`

Closes: aptos-labs#9411
  • Loading branch information
meng-xu-cs authored and bors-libra committed Oct 21, 2021
1 parent 99cbb52 commit 727a4e2
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions language/move-prover/tools/spec-flatten/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,12 @@ pub struct FlattenOptions {
pub pipeline: Vec<SimplificationPass>,

/// Dump stepwise result
#[structopt(long)]
pub dump: bool,
#[structopt(long = "dump-stepwise")]
pub dump_stepwise: bool,

/// Dump stepwise result in raw exp printing format
#[structopt(long = "dump-stepwise-raw", requires = "dump-stepwise")]
pub dump_stepwise_raw: bool,
}

//**************************************************************************************************
Expand Down Expand Up @@ -106,7 +110,7 @@ pub fn run(options: &FlattenOptions) -> Result<()> {
// prepare for stepwise result printing
let fun_scope = SpecBlockTarget::Function(fun_id.module_id, fun_id.id);
let printer = SpecPrinter::new(&env, &fun_scope);
if options.dump {
if options.dump_stepwise {
println!(
"================ fun {} ================",
fun_env.get_full_name_str()
Expand All @@ -127,10 +131,14 @@ pub fn run(options: &FlattenOptions) -> Result<()> {
}?;

// dump stepwise results if requested
if options.dump {
if options.dump_stepwise {
println!("step {} - {:?} {{", i, pass);
for cond in &new_spec.conditions {
println!("\t{}", SpecPrinter::convert(printer.print_condition(cond)));
if options.dump_stepwise_raw {
println!("\t{:?} {}", cond.kind, cond.exp.display(&env));
} else {
println!("\t{}", SpecPrinter::convert(printer.print_condition(cond)));
}
}
println!("}}");
}
Expand Down

0 comments on commit 727a4e2

Please sign in to comment.