debug outputs in order
This commit is contained in:
parent
3ac50f974d
commit
6707b2bb9c
@ -22,18 +22,18 @@ impl Default for ExecutionMethod {
|
|||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct UnfinishedComputation {
|
pub struct UnfinishedComputation {
|
||||||
artifacts: HashMap<String, TraceArtifact>,
|
artifacts: Vec<(String, TraceArtifact)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct FinishedComputation {
|
pub struct FinishedComputation {
|
||||||
artifacts: HashMap<String, TraceArtifact>,
|
artifacts: Vec<(String, TraceArtifact)>,
|
||||||
text_output: Result<String, String>,
|
text_output: Result<String, String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UnfinishedComputation {
|
impl UnfinishedComputation {
|
||||||
pub fn add_artifact(&mut self, artifact: TraceArtifact) {
|
pub fn add_artifact(&mut self, artifact: TraceArtifact) {
|
||||||
self.artifacts.insert(artifact.stage_name.clone(), artifact);
|
self.artifacts.push((artifact.stage_name.clone(), artifact));
|
||||||
}
|
}
|
||||||
pub fn finish(self, text_output: Result<String, String>) -> FinishedComputation {
|
pub fn finish(self, text_output: Result<String, String>) -> FinishedComputation {
|
||||||
FinishedComputation {
|
FinishedComputation {
|
||||||
@ -69,14 +69,12 @@ impl FinishedComputation {
|
|||||||
match self.text_output {
|
match self.text_output {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
let mut buf = String::new();
|
let mut buf = String::new();
|
||||||
for stage in ["tokens", "parse_trace", "ast", "symbol_table", "type_check"].iter() {
|
for (stage, artifact) in self.artifacts.iter() {
|
||||||
if let Some(artifact) = self.artifacts.get(&stage.to_string()) {
|
|
||||||
let color = artifact.text_color;
|
let color = artifact.text_color;
|
||||||
let stage = stage.color(color).bold();
|
let stage = stage.color(color).bold();
|
||||||
let output = artifact.debug_output.color(color);
|
let output = artifact.debug_output.color(color);
|
||||||
write!(&mut buf, "{}: {}\n", stage, output).unwrap();
|
write!(&mut buf, "{}: {}\n", stage, output).unwrap();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if buf == "" { None } else { Some(buf) }
|
if buf == "" { None } else { Some(buf) }
|
||||||
},
|
},
|
||||||
Err(ref s) => Some(format!("{} {}", "Error: ".red().bold(), s))
|
Err(ref s) => Some(format!("{} {}", "Error: ".red().bold(), s))
|
||||||
@ -117,7 +115,7 @@ impl TraceArtifact {
|
|||||||
|
|
||||||
pub trait ProgrammingLanguageInterface {
|
pub trait ProgrammingLanguageInterface {
|
||||||
fn execute_pipeline(&mut self, _input: &str, _eval_options: &EvalOptions) -> FinishedComputation {
|
fn execute_pipeline(&mut self, _input: &str, _eval_options: &EvalOptions) -> FinishedComputation {
|
||||||
FinishedComputation { artifacts: HashMap::new(), text_output: Err(format!("Execution pipeline not done")) }
|
FinishedComputation { artifacts: vec![], text_output: Err(format!("Execution pipeline not done")) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_language_name(&self) -> String;
|
fn get_language_name(&self) -> String;
|
||||||
|
Loading…
Reference in New Issue
Block a user