add provisional max_depth option to write_term, speed printing of non-cyclic terms

This commit is contained in:
Mark Thom
2020-03-15 00:09:20 -06:00
parent 3620f72b6c
commit 325df8a6e3
6 changed files with 379 additions and 95 deletions

View File

@@ -2667,6 +2667,7 @@ impl MachineState {
let ignore_ops = self.store(self.deref(self[temp_v!(2)].clone()));
let numbervars = self.store(self.deref(self[temp_v!(3)].clone()));
let quoted = self.store(self.deref(self[temp_v!(4)].clone()));
let max_depth = self.store(self.deref(self[temp_v!(6)].clone()));
let mut printer = HCPrinter::new(&self, &indices.op_dir, PrinterOutputter::new());
@@ -2682,6 +2683,15 @@ impl MachineState {
printer.quoted = name.as_str() == "true";
}
if let &Addr::Con(Constant::Integer(ref n)) = &max_depth {
if let Some(n) = n.to_usize() {
printer.max_depth = n;
} else {
self.fail = true;
return Ok(());
}
}
let stub = MachineError::functor_stub(clause_name!("write_term"), 2);
match self.try_from_list(temp_v!(5), stub.clone()) {