Thread debug opts around where they need to be

This commit is contained in:
greg 2018-07-03 03:39:43 -07:00
parent 1761d11d36
commit 072eab1a80
2 changed files with 9 additions and 5 deletions

View File

@ -79,6 +79,7 @@ fn parsing(_handle: &mut Schala, input: Vec<tokenizing::Token>, comp: Option<&mu
let (ast, trace) = parsing::parse(input); let (ast, trace) = parsing::parse(input);
comp.map(|comp| { comp.map(|comp| {
println!("DEBUG OPTS: {:?}", comp.cur_debug_options);
//TODO need to control which of these debug stages get added //TODO need to control which of these debug stages get added
comp.add_artifact(TraceArtifact::new_parse_trace(trace)); comp.add_artifact(TraceArtifact::new_parse_trace(trace));
comp.add_artifact(TraceArtifact::new("ast", format!("{:#?}", ast))); comp.add_artifact(TraceArtifact::new("ast", format!("{:#?}", ast)));

View File

@ -29,6 +29,7 @@ impl Default for ExecutionMethod {
#[derive(Debug, Default)] #[derive(Debug, Default)]
pub struct UnfinishedComputation { pub struct UnfinishedComputation {
artifacts: Vec<(String, TraceArtifact)>, artifacts: Vec<(String, TraceArtifact)>,
pub cur_debug_options: Vec<String>,
} }
#[derive(Debug)] #[derive(Debug)]
@ -161,11 +162,13 @@ macro_rules! pass_chain_helper {
let pass_name = stringify!($pass); let pass_name = stringify!($pass);
let output = { let output = {
let ref debug_map = $options.debug_passes; let ref debug_map = $options.debug_passes;
//let (debug_handle: Option<&mut UnfinishedComputation>, debug_opts) = if debug_set.contains_key(pass_name) { let debug_handle = match debug_map.get(pass_name) {
//let (debug_handle: Option<&mut UnfinishedComputation>, debug_opts: Vec<String>) = match debug_map.get(pass_name) { Some(PassDebugDescriptor { opts }) => { //(Some(&mut $comp), Some(opts.clone())),
let (debug_handle, debug_opts) = match debug_map.get(pass_name) { let ptr = &mut $comp;
Some(PassDebugDescriptor { opts }) => (Some(&mut $comp), Some(opts.clone())), ptr.cur_debug_options = opts.clone();
_ => (None, None) Some(ptr)
}
_ => None
}; };
$pass($state, $input, debug_handle) $pass($state, $input, debug_handle)
}; };