mark cyclic lists with ellipses at the head (#2635)
This commit is contained in:
@@ -874,12 +874,16 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> {
|
|||||||
None => {
|
None => {
|
||||||
if self.max_depth == 0 || *max_depth == 0 {
|
if self.max_depth == 0 || *max_depth == 0 {
|
||||||
// otherwise, contract it to an ellipsis.
|
// otherwise, contract it to an ellipsis.
|
||||||
push_space_if_amb!(self, "...", {
|
self.state_stack.push(TokenOrRedirect::Atom(atom!("...")));
|
||||||
append_str!(self, "...");
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
debug_assert!(cell.is_ref());
|
debug_assert!(cell.is_ref());
|
||||||
|
|
||||||
|
let h = cell.get_value() as usize;
|
||||||
|
self.iter.push_stack(IterStackLoc::iterable_loc(
|
||||||
|
h,
|
||||||
|
HeapOrStackTag::Heap,
|
||||||
|
));
|
||||||
|
|
||||||
// as usual, the WAM's
|
// as usual, the WAM's
|
||||||
// optimization of the Lis tag
|
// optimization of the Lis tag
|
||||||
// (conflating the location of
|
// (conflating the location of
|
||||||
@@ -889,14 +893,16 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> {
|
|||||||
// lest we find ourselves in
|
// lest we find ourselves in
|
||||||
// an infinite loop.
|
// an infinite loop.
|
||||||
if cell.get_tag() == HeapCellValueTag::Lis {
|
if cell.get_tag() == HeapCellValueTag::Lis {
|
||||||
|
if self.iter.heap[cell.get_value() as usize]
|
||||||
|
.get_forwarding_bit()
|
||||||
|
{
|
||||||
|
self.state_stack
|
||||||
|
.push(TokenOrRedirect::Atom(atom!("...")));
|
||||||
|
return None;
|
||||||
|
} else {
|
||||||
*max_depth -= 1;
|
*max_depth -= 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
let h = cell.get_value() as usize;
|
|
||||||
self.iter.push_stack(IterStackLoc::iterable_loc(
|
|
||||||
h,
|
|
||||||
HeapOrStackTag::Heap,
|
|
||||||
));
|
|
||||||
|
|
||||||
if let Some(cell) = self.iter.next() {
|
if let Some(cell) = self.iter.next() {
|
||||||
orig_cell = cell;
|
orig_cell = cell;
|
||||||
|
|||||||
Reference in New Issue
Block a user