Fix bug with debug specifications

This commit is contained in:
greg 2019-08-05 03:31:10 -07:00
parent d832583ed9
commit 16bf166fa9

View File

@ -238,22 +238,23 @@ impl ProgrammingLanguageInterface for Schala {
let stage_names = stage_names(); let stage_names = stage_names();
let cur_stage_name = stage_names[n]; let cur_stage_name = stage_names[n];
let ask = token.debug_requests.iter().find(|ask| ask.is_for_stage(cur_stage_name)); let ask = token.debug_requests.iter().find(|ask| ask.is_for_stage(cur_stage_name));
let mut debug_artifact = ask.and_then(|ask| match ask {
DebugAsk::ByStage { token, .. } => token.as_ref(), let parsing = match ask {
_ => None Some(DebugAsk::ByStage { token, .. }) if cur_stage_name == "parsing" => Some(
}).map(|token| { token.as_ref().map(|token| match &token[..] {
let parsing = if cur_stage_name != "parsing" {
None
} else {
Some(match &token[..] {
"compact" => ParsingDebugType::CompactAST, "compact" => ParsingDebugType::CompactAST,
"expanded" => ParsingDebugType::ExpandedAST, "expanded" => ParsingDebugType::ExpandedAST,
"trace" => ParsingDebugType::Trace, "trace" => ParsingDebugType::Trace,
_ => ParsingDebugType::CompactAST, _ => ParsingDebugType::CompactAST,
}) }).unwrap_or(ParsingDebugType::CompactAST)
}; ),
PassDebugArtifact { parsing, ..Default::default() } _ => None,
};
let mut debug_artifact = ask.map(|_| PassDebugArtifact {
parsing, ..Default::default()
}); });
let output = func(input, token.schala, debug_artifact.as_mut()); let output = func(input, token.schala, debug_artifact.as_mut());
token.stage_durations.push((cur_stage_name.to_string(), token.sw.elapsed())); token.stage_durations.push((cur_stage_name.to_string(), token.sw.elapsed()));