]> Repositorios git - scryer-prolog.git/commitdiff
mark variable referents in stackful iterator, fix tests (#1408)
authorMark Thom <[email protected]>
Sun, 10 Apr 2022 20:17:33 +0000 (14:17 -0600)
committerMark Thom <[email protected]>
Sun, 10 Apr 2022 20:17:47 +0000 (14:17 -0600)
src/heap_iter.rs
src/loader.pl

index b8670de35ea3cdc072fc2cae2185b59036c68530..a7a7e7b6ee1e3e03977a7dfdba0703621413ad18 100644 (file)
@@ -171,8 +171,8 @@ impl<'a> StackfulPreOrderHeapIter<'a> {
                    return Some(self.heap[h]);
                }
                (HeapCellValueTag::AttrVar | HeapCellValueTag::PStrLoc | HeapCellValueTag::Var, vh) => {
-                   self.push_if_unmarked(h);
-                   self.stack.push(IterStackLoc::iterable_heap_loc(vh));
+                   self.push_if_unmarked(vh);
+                   self.stack.push(IterStackLoc::mark_heap_loc(vh));
                    forward_if_referent_marked(&mut self.heap, vh);
                }
                (HeapCellValueTag::PStrOffset, offset) => {
@@ -1467,7 +1467,7 @@ mod tests {
             );
             assert_eq!(
                 unmark_cell_bits!(iter.next().unwrap()),
-                list_loc_as_cell!(1)
+                heap_loc_as_cell!(0)
             );
 
             assert_eq!(iter.next(), None);
@@ -1739,7 +1739,10 @@ mod tests {
             cyclic_link.set_forwarding_bit(true);
             cyclic_link.set_mark_bit(true);
 
-            assert_eq!(iter.next().unwrap(), list_loc_as_cell!(1));
+            assert_eq!(
+                unmark_cell_bits!(iter.next().unwrap()),
+                list_loc_as_cell!(1)
+            );
             assert_eq!(
                 unmark_cell_bits!(iter.next().unwrap()),
                 list_loc_as_cell!(1)
@@ -1803,7 +1806,7 @@ mod tests {
 
             assert_eq!(
                 unmark_cell_bits!(iter.next().unwrap()),
-                str_loc_as_cell!(1)
+                heap_loc_as_cell!(0)
             );
 
             assert_eq!(
@@ -1975,7 +1978,7 @@ mod tests {
             );
             assert_eq!(
                 unmark_cell_bits!(iter.next().unwrap()),
-                list_loc_as_cell!(1)
+                heap_loc_as_cell!(0)
             );
             assert_eq!(
                 unmark_cell_bits!(iter.next().unwrap()),
index a597855042137302e03de3338d4d856986f7c0fd..ba036061c043994641e99e0d12c09739b00f6e33 100644 (file)
@@ -28,11 +28,10 @@ write_error(Error) :-
     ),
     (  nonvar(Error),
        functor(Error, error, 2) ->
-       writeq(Error),
-       write('.')
-    ;  writeq(throw(Error)),
-       write('.')
-    ).
+       writeq(Error)
+    ;  writeq(throw(Error))
+    ),
+    write('.').
 
 '$print_message_and_fail'(Error) :-
     (  (  Error = error(existence_error(procedure, Expansion), Expansion)