use codespan_reporting::diagnostic::Severity;
use move_model::model::{GlobalEnv, VerificationScope};
use serde::{Deserialize, Serialize};
use std::rc::Rc;
#[derive(Debug, Copy, Clone, Serialize, Deserialize)]
pub enum AutoTraceLevel {
Off,
VerifiedFunction,
AllFunctions,
}
impl AutoTraceLevel {
pub fn verified_functions(self) -> bool {
use AutoTraceLevel::*;
matches!(self, VerifiedFunction | AllFunctions)
}
pub fn functions(self) -> bool {
use AutoTraceLevel::*;
matches!(self, AllFunctions)
}
pub fn invariants(self) -> bool {
use AutoTraceLevel::*;
matches!(self, VerifiedFunction | AllFunctions)
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(default, deny_unknown_fields)]
pub struct ProverOptions {
pub generate_only: bool,
pub native_stubs: bool,
pub minimize_execution_trace: bool,
pub omit_model_debug: bool,
pub stable_test_output: bool,
pub verify_scope: VerificationScope,
pub resource_wellformed_axiom: bool,
pub assume_wellformed_on_access: bool,
pub mutation: bool,
pub mutation_add_sub: usize,
pub mutation_sub_add: usize,
pub mutation_mul_div: usize,
pub mutation_div_mul: usize,
pub boogie_poly: bool,
pub deep_pack_unpack: bool,
pub auto_trace_level: AutoTraceLevel,
pub report_severity: Severity,
pub dump_bytecode: bool,
pub dump_cfg: bool,
pub num_instances: usize,
pub sequential_task: bool,
pub check_inconsistency: bool,
pub unconditional_abort_as_inconsistency: bool,
pub for_interpretation: bool,
}
impl Default for ProverOptions {
fn default() -> Self {
Self {
generate_only: false,
native_stubs: false,
minimize_execution_trace: true,
omit_model_debug: false,
stable_test_output: false,
verify_scope: VerificationScope::All,
resource_wellformed_axiom: false,
assume_wellformed_on_access: false,
mutation: false,
mutation_add_sub: 0,
mutation_sub_add: 0,
mutation_mul_div: 0,
mutation_div_mul: 0,
boogie_poly: false,
deep_pack_unpack: false,
auto_trace_level: AutoTraceLevel::Off,
report_severity: Severity::Warning,
dump_bytecode: false,
dump_cfg: false,
num_instances: 1,
sequential_task: false,
check_inconsistency: false,
unconditional_abort_as_inconsistency: false,
for_interpretation: false,
}
}
}
impl ProverOptions {
pub fn get(env: &GlobalEnv) -> Rc<ProverOptions> {
if !env.has_extension::<ProverOptions>() {
env.set_extension(ProverOptions::default())
}
env.get_extension::<ProverOptions>().unwrap()
}
pub fn set(env: &GlobalEnv, options: ProverOptions) {
env.set_extension::<ProverOptions>(options);
}
}