Implement debug stages as a HashSet of strings
Change to custom enum type later
This commit is contained in:
parent
27885500fd
commit
061d54702f
@ -1,4 +1,4 @@
|
||||
use std::collections::HashMap;
|
||||
use std::collections::{HashSet, HashMap};
|
||||
use colored::*;
|
||||
use std::fmt::Write;
|
||||
|
||||
@ -7,7 +7,8 @@ pub struct LLVMCodeString(pub String);
|
||||
#[derive(Debug, Default, Serialize, Deserialize)]
|
||||
pub struct EvalOptions {
|
||||
pub debug: DebugOptions,
|
||||
pub execution_method: ExecutionMethod
|
||||
pub execution_method: ExecutionMethod,
|
||||
pub debug_stages: HashSet<String>,
|
||||
}
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub enum ExecutionMethod {
|
||||
|
@ -294,14 +294,23 @@ impl Repl {
|
||||
Some(&"stages") => Some(stages.into_iter().intersperse(format!(" -> ")).collect()),
|
||||
b @ Some(&"show") | b @ Some(&"hide") => {
|
||||
let show = b == Some(&"show");
|
||||
let debug_stage = match commands.get(2) {
|
||||
Some(s) => s,
|
||||
let debug_stage: String = match commands.get(2) {
|
||||
Some(s) => s.to_string(),
|
||||
None => return Some(format!("Must specify a stage to debug")),
|
||||
};
|
||||
let maybe_debug = stages.iter().find(|stage_name| stage_name == debug_stage);
|
||||
match maybe_debug {
|
||||
Some(s) => Some(format!("Will debug {}", s)),
|
||||
None => Some(format!("couldn't find it"))
|
||||
let maybe_debug = stages.iter().find(|stage_name| **stage_name == debug_stage);
|
||||
match (show, maybe_debug) {
|
||||
(true, Some(s)) => {
|
||||
let msg = format!("Enabling debug for stage {}", debug_stage);
|
||||
self.options.debug_stages.insert(debug_stage);
|
||||
Some(msg)
|
||||
},
|
||||
(false, Some(s)) => {
|
||||
let msg = format!("Disabling debug for stage {}", debug_stage);
|
||||
self.options.debug_stages.remove(&debug_stage);
|
||||
Some(msg)
|
||||
},
|
||||
(_, None) => Some(format!("couldn't find it"))
|
||||
}
|
||||
},
|
||||
_ => Some(format!("Unknown debug command"))
|
||||
|
Loading…
Reference in New Issue
Block a user