Put back rudimentary debug output
This commit is contained in:
parent
856c0f95ce
commit
78d1e93e4b
@ -266,7 +266,8 @@ impl ProgrammingLanguageInterface for Schala {
|
|||||||
schala: &'a mut Schala,
|
schala: &'a mut Schala,
|
||||||
stage_durations: &'a mut Vec<(String, Duration)>,
|
stage_durations: &'a mut Vec<(String, Duration)>,
|
||||||
sw: &'a Stopwatch,
|
sw: &'a Stopwatch,
|
||||||
debug_requests: &'a HashSet<DebugAsk>
|
debug_requests: &'a HashSet<DebugAsk>,
|
||||||
|
debug_responses: &'a mut Vec<DebugResponse>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn output_wrapper<Input, Output, F>(n: usize, func: F, input: Input, tok: &mut PassToken) -> Result<Output, String>
|
fn output_wrapper<Input, Output, F>(n: usize, func: F, input: Input, tok: &mut PassToken) -> Result<Output, String>
|
||||||
@ -280,6 +281,15 @@ impl ProgrammingLanguageInterface for Schala {
|
|||||||
};
|
};
|
||||||
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 {
|
||||||
|
for value in artifact.artifacts.into_iter() {
|
||||||
|
let resp = DebugResponse {
|
||||||
|
ask: DebugAsk::ByStage { stage_name: stage_names[n].to_string() },
|
||||||
|
value,
|
||||||
|
};
|
||||||
|
tok.debug_responses.push(resp);
|
||||||
|
}
|
||||||
|
}
|
||||||
output
|
output
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,7 +297,8 @@ impl ProgrammingLanguageInterface for Schala {
|
|||||||
self.source_reference.load_new_source(source);
|
self.source_reference.load_new_source(source);
|
||||||
let sw = Stopwatch::start_new();
|
let sw = Stopwatch::start_new();
|
||||||
let mut stage_durations = Vec::new();
|
let mut stage_durations = Vec::new();
|
||||||
let mut tok = PassToken { schala: self, stage_durations: &mut stage_durations, sw: &sw, debug_requests: &debug_requests };
|
let mut debug_responses = Vec::new();
|
||||||
|
let mut tok = PassToken { schala: self, stage_durations: &mut stage_durations, sw: &sw, debug_requests: &debug_requests, debug_responses: &mut debug_responses };
|
||||||
|
|
||||||
let main_output: Result<String, String> = Ok(source)
|
let main_output: Result<String, String> = Ok(source)
|
||||||
.and_then(|source| output_wrapper(0, tokenizing, source, &mut tok))
|
.and_then(|source| output_wrapper(0, tokenizing, source, &mut tok))
|
||||||
@ -305,7 +316,7 @@ impl ProgrammingLanguageInterface for Schala {
|
|||||||
ComputationResponse {
|
ComputationResponse {
|
||||||
main_output,
|
main_output,
|
||||||
global_output_stats,
|
global_output_stats,
|
||||||
debug_responses: vec![],
|
debug_responses,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ use std::collections::HashSet;
|
|||||||
use colored::*;
|
use colored::*;
|
||||||
use crate::language::{ProgrammingLanguageInterface,
|
use crate::language::{ProgrammingLanguageInterface,
|
||||||
ComputationRequest, ComputationResponse,
|
ComputationRequest, ComputationResponse,
|
||||||
LangMetaRequest, LangMetaResponse};
|
DebugAsk};
|
||||||
|
|
||||||
mod command_tree;
|
mod command_tree;
|
||||||
use self::command_tree::{CommandTree, BoxedCommandFunction};
|
use self::command_tree::{CommandTree, BoxedCommandFunction};
|
||||||
@ -202,6 +202,16 @@ impl Repl {
|
|||||||
buf.push_str(&format!("{:?}\n", response.global_output_stats.stage_durations));
|
buf.push_str(&format!("{:?}\n", response.global_output_stats.stage_durations));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for debug_resp in response.debug_responses {
|
||||||
|
let stage_name = match debug_resp.ask {
|
||||||
|
DebugAsk::ByStage { stage_name } => stage_name,
|
||||||
|
_ => continue,
|
||||||
|
};
|
||||||
|
let s = format!("{} - {}\n", stage_name, debug_resp.value);
|
||||||
|
buf.push_str(&s);
|
||||||
|
}
|
||||||
|
|
||||||
buf.push_str(&match response.main_output {
|
buf.push_str(&match response.main_output {
|
||||||
Ok(s) => s,
|
Ok(s) => s,
|
||||||
Err(e) => format!("{} {}", "Error".red(), e)
|
Err(e) => format!("{} {}", "Error".red(), e)
|
||||||
|
Loading…
Reference in New Issue
Block a user