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);
comp.map(|comp| {
println!("DEBUG OPTS: {:?}", comp.cur_debug_options);
//TODO need to control which of these debug stages get added
comp.add_artifact(TraceArtifact::new_parse_trace(trace));
comp.add_artifact(TraceArtifact::new("ast", format!("{:#?}", ast)));

View File

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