Make output_wrapper more concise

This commit is contained in:
greg 2019-06-18 18:11:17 -07:00
parent b6e3469573
commit 2ec3b21ebf
2 changed files with 4 additions and 23 deletions

14
TODO.md
View File

@ -105,17 +105,3 @@ if the only two guard patterns are true and false, then the abbreviated syntax:
`'if' discriminator 'then' block_or_expr 'else' block_or_expr` `'if' discriminator 'then' block_or_expr 'else' block_or_expr`
can replace `'if' discriminator '{' 'true' 'then' block_or_expr; 'false' 'then' block_or_expr '}'` can replace `'if' discriminator '{' 'true' 'then' block_or_expr; 'false' 'then' block_or_expr '}'`

View File

@ -275,19 +275,14 @@ impl ProgrammingLanguageInterface for Schala {
where F: Fn(Input, &mut Schala, Option<&mut PassDebugArtifact>) -> Result<Output, String> where F: Fn(Input, &mut Schala, Option<&mut PassDebugArtifact>) -> Result<Output, String>
{ {
let stage_names = stage_names(); let stage_names = stage_names();
let mut debug_artifact = if tok.debug_requests.contains(&DebugAsk::ByStage { stage_name: stage_names[n].to_string() }) { let ask = DebugAsk::ByStage { stage_name: stage_names[n].to_string() };
Some(PassDebugArtifact::default()) let mut debug_artifact = tok.debug_requests.get(&ask).map(|_| PassDebugArtifact::default());
} else {
None
};
let output = func(input, tok.schala, debug_artifact.as_mut()); let output = func(input, tok.schala, debug_artifact.as_mut());
tok.stage_durations.push((stage_names[n].to_string(), tok.sw.elapsed())); tok.stage_durations.push((stage_names[n].to_string(), tok.sw.elapsed()));
if let Some(artifact) = debug_artifact { if let Some(artifact) = debug_artifact {
for value in artifact.artifacts.into_iter() { for value in artifact.artifacts.into_iter() {
let resp = DebugResponse { let resp = DebugResponse { ask: ask.clone(), value };
ask: DebugAsk::ByStage { stage_name: stage_names[n].to_string() },
value,
};
tok.debug_responses.push(resp); tok.debug_responses.push(resp);
} }
} }