]> Repositorios git - scryer-prolog.git/commitdiff
limit use of stackless iterator to test suite
authorMark Thom <[email protected]>
Wed, 6 Apr 2022 03:02:39 +0000 (21:02 -0600)
committerMark Thom <[email protected]>
Wed, 6 Apr 2022 03:02:39 +0000 (21:02 -0600)
src/heap_iter.rs
src/machine/arithmetic_ops.rs
src/machine/gc.rs

index fdbc6254f3c736eb5f434793afba0ed87eb46eb5..21a65dbdb05ffaffc2a481a2a8be017def8f235d 100644 (file)
@@ -1,3 +1,4 @@
+#[cfg(test)]
 pub(crate) use crate::machine::gc::{IteratorUMP, StacklessPreOrderHeapIter};
 use crate::machine::heap::*;
 
@@ -223,6 +224,7 @@ impl<'a> Iterator for StackfulPreOrderHeapIter<'a> {
     }
 }
 
+#[cfg(test)]
 #[inline(always)]
 pub(crate) fn stackless_preorder_iter(
     heap: &mut Vec<HeapCellValue>,
@@ -335,9 +337,11 @@ pub(crate) fn stackful_post_order_iter<'a>(
     PostOrderIterator::new(StackfulPreOrderHeapIter::new(heap, cell))
 }
 
+#[cfg(test)]
 pub(crate) type RightistPostOrderHeapIter<'a> =
     PostOrderIterator<StacklessPreOrderHeapIter<'a, IteratorUMP>>;
 
+#[cfg(test)]
 #[inline]
 pub(crate) fn stackless_post_order_iter<'a>(
     heap: &'a mut Heap,
@@ -440,7 +444,7 @@ mod tests {
             ]
         ));
 
-        for _ in 0..200 { // 000 {
+        for _ in 0..200000 {
             let mut iter = stackless_preorder_iter(&mut wam.machine_st.heap, heap_loc_as_cell!(0));
 
             assert_eq!(
index d66fc8e05e8fc93880532c6bf61e495cb738d8eb..01dd9d55b8187673d8c7b9633914cea604b1aa39 100644 (file)
@@ -1098,7 +1098,7 @@ impl MachineState {
 
     pub(crate) fn arith_eval_by_metacall(&mut self, value: HeapCellValue) -> Result<Number, MachineStub> {
         let stub_gen = || functor_stub(atom!("is"), 2);
-        let mut iter = stackless_post_order_iter(&mut self.heap, value);
+        let mut iter = stackful_post_order_iter(&mut self.heap, value);
 
         while let Some(value) = iter.next() {
             if value.get_forwarding_bit() {
@@ -1125,8 +1125,8 @@ impl MachineState {
             read_heap_cell!(value,
                 (HeapCellValueTag::Atom, (name, arity)) => {
                     if arity == 2 {
-                        let a1 = self.interms.pop().unwrap();
                         let a2 = self.interms.pop().unwrap();
+                        let a1 = self.interms.pop().unwrap();
 
                         match name {
                             atom!("+") => self.interms.push(drop_iter_on_err!(
index a56580ad0ec2597a05e4551d1774c3cd47c1bf59..05bd70d612507d523bd8c3dd9ef9fbeab49fcbb0 100644 (file)
@@ -104,6 +104,7 @@ impl<'a> StacklessPreOrderHeapIter<'a, MarkerUMP> {
 }
 
 impl<'a> StacklessPreOrderHeapIter<'a, IteratorUMP> {
+    #[cfg(test)]
     pub(crate) fn new(heap: &'a mut Vec<HeapCellValue>, cell: HeapCellValue) -> Self {
         let orig_heap_len = heap.len();
         let start = orig_heap_len + 1;