Made evaluation-printing more sophisticated

This commit is contained in:
greg 2017-01-11 22:29:38 -08:00
parent d9ab5a58cf
commit a46ede9395

View File

@ -133,13 +133,25 @@ impl<'a> Evaluator<'a> {
} }
fn step(&mut self, node: Statement) -> Statement { fn step(&mut self, node: Statement) -> Statement {
let mut trace = String::new();
if self.trace_evaluation { if self.trace_evaluation {
println!("Step: {:?}", node); trace.push_str(&format!("Step: {:?}", node));
} }
let (new_node, side_effect) = self.reduce_astnode(node); let (new_node, side_effect) = self.reduce_astnode(node);
if self.trace_evaluation {
trace.push_str(&format!("{:?}", new_node));
}
if let Some(s) = side_effect { if let Some(s) = side_effect {
if self.trace_evaluation {
trace.push_str(&format!(" | side-effect: {:?}", s));
}
self.perform_side_effect(s); self.perform_side_effect(s);
} }
if self.trace_evaluation {
println!("{}", trace);
}
new_node new_node
} }