update toplevel comments, add mutable stack to zipped acyclic iterators
This commit is contained in:
@@ -120,10 +120,11 @@ impl<'a> Iterator for HCPreOrderIterator<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait MutStackHCIterator
|
pub trait MutStackHCIterator<'b> where Self: Iterator
|
||||||
where Self: Iterator<Item = Addr>
|
|
||||||
{
|
{
|
||||||
fn stack(&mut self) -> &mut Vec<Addr>;
|
type MutStack;
|
||||||
|
|
||||||
|
fn stack(&'b mut self) -> Self::MutStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct HCPostOrderIterator<'a> {
|
pub struct HCPostOrderIterator<'a> {
|
||||||
@@ -220,8 +221,10 @@ impl MachineState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> MutStackHCIterator for HCPreOrderIterator<'a> {
|
impl<'b, 'a: 'b> MutStackHCIterator<'b> for HCPreOrderIterator<'a> {
|
||||||
fn stack(&mut self) -> &mut Vec<Addr> {
|
type MutStack = &'b mut Vec<Addr>;
|
||||||
|
|
||||||
|
fn stack(&'b mut self) -> Self::MutStack {
|
||||||
&mut self.state_stack
|
&mut self.state_stack
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -273,6 +276,14 @@ pub struct HCZippedAcyclicIterator<'a> {
|
|||||||
pub first_to_expire: Ordering,
|
pub first_to_expire: Ordering,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'b, 'a: 'b> MutStackHCIterator<'b> for HCZippedAcyclicIterator<'a> {
|
||||||
|
type MutStack = (&'b mut Vec<Addr>, &'b mut Vec<Addr>);
|
||||||
|
|
||||||
|
fn stack(&'b mut self) -> Self::MutStack {
|
||||||
|
(self.i1.stack(), self.i2.stack())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'a> HCZippedAcyclicIterator<'a> {
|
impl<'a> HCZippedAcyclicIterator<'a> {
|
||||||
pub fn new(i1: HCPreOrderIterator<'a>, i2: HCPreOrderIterator<'a>) -> Self {
|
pub fn new(i1: HCPreOrderIterator<'a>, i2: HCPreOrderIterator<'a>) -> Self {
|
||||||
HCZippedAcyclicIterator {
|
HCZippedAcyclicIterator {
|
||||||
@@ -293,6 +304,7 @@ impl<'a> Iterator for HCZippedAcyclicIterator<'a>
|
|||||||
if !self.seen.contains(&(a1.clone(), a2.clone())) {
|
if !self.seen.contains(&(a1.clone(), a2.clone())) {
|
||||||
self.i1.stack().push(a1.clone());
|
self.i1.stack().push(a1.clone());
|
||||||
self.i2.stack().push(a2.clone());
|
self.i2.stack().push(a2.clone());
|
||||||
|
|
||||||
self.seen.insert((a1, a2));
|
self.seen.insert((a1, a2));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ impl MachineError {
|
|||||||
pub(super)
|
pub(super)
|
||||||
fn interrupt_error() -> Self {
|
fn interrupt_error() -> Self {
|
||||||
let stub = functor!("$interrupt_thrown");
|
let stub = functor!("$interrupt_thrown");
|
||||||
|
|
||||||
MachineError {
|
MachineError {
|
||||||
stub,
|
stub,
|
||||||
location: None,
|
location: None,
|
||||||
|
|||||||
@@ -1969,7 +1969,8 @@ impl MachineState {
|
|||||||
iter.first_to_expire != Ordering::Equal
|
iter.first_to_expire != Ordering::Equal
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn compare_term_test(&self, a1: &Addr, a2: &Addr) -> Option<Ordering> {
|
pub(super)
|
||||||
|
fn compare_term_test(&self, a1: &Addr, a2: &Addr) -> Option<Ordering> {
|
||||||
let mut iter = self.zipped_acyclic_pre_order_iter(*a1, *a2);
|
let mut iter = self.zipped_acyclic_pre_order_iter(*a1, *a2);
|
||||||
|
|
||||||
while let Some((v1, v2)) = iter.next() {
|
while let Some((v1, v2)) = iter.next() {
|
||||||
|
|||||||
@@ -214,7 +214,10 @@ gather_goals([Var = Value | Pairs], VarList, Goals) :-
|
|||||||
).
|
).
|
||||||
|
|
||||||
print_exception(E) :-
|
print_exception(E) :-
|
||||||
( E == error('$interrupt_thrown', repl) -> nl % print the exception on a newline to evade "^C".
|
( E == error('$interrupt_thrown', repl) -> nl % print the
|
||||||
|
% exception on a
|
||||||
|
% newline to evade
|
||||||
|
% "^C".
|
||||||
; true
|
; true
|
||||||
),
|
),
|
||||||
write_term('caught: ', [quoted(false), max_depth(20)]),
|
write_term('caught: ', [quoted(false), max_depth(20)]),
|
||||||
|
|||||||
Reference in New Issue
Block a user