]> Repositorios git - scryer-prolog.git/commitdiff
correct copier.
authorMark Thom <[email protected]>
Sun, 16 Sep 2018 08:32:29 +0000 (02:32 -0600)
committerMark Thom <[email protected]>
Sun, 16 Sep 2018 08:32:29 +0000 (02:32 -0600)
src/prolog/copier.rs
src/prolog/heap_iter.rs

index 7d15cb5dc84eab27c1c00706004536e5ba2a258b..6b206abbe4339ae89e55a9880777fb73951b1428 100644 (file)
@@ -3,20 +3,12 @@ use prolog::instructions::*;
 
 use std::ops::IndexMut;
 
-//type ListTrail = HashMap<usize, usize>;
 type Trail = Vec<(Ref, HeapCellValue)>;
 
 pub(crate) struct RedirectInfo {
-    //list_trail: ListTrail,
     trail: Trail
 }
-/*
-impl RedirectInfo {
-    fn new() -> Self {
-        RedirectInfo { list_trail: ListTrail::new(), trail: Trail::new() }
-    }
-}
-*/
+
 pub(crate) trait CopierTarget
 {
     fn source(&self) -> usize;
@@ -50,16 +42,15 @@ pub(crate) trait CopierTarget
             self.stack()[fr][sc] = Addr::HeapCell(scan);
             trail.push((Ref::StackCell(fr, sc),
                         HeapCellValue::Addr(Addr::StackCell(fr, sc))));
-        }        
+        }
     }
-    
+
     // duplicate_term_impl(L1, L2) uses Cheney's algorithm to copy the term
     // at L1 to L2. trail is kept to restore the innards of L1 after
     // it's been copied to L2.
     fn duplicate_term_impl(&mut self, addr: Addr) -> RedirectInfo
       where Self: IndexMut<usize, Output=HeapCellValue>
     {
-        // let mut redirect_info = RedirectInfo::new();
         let mut trail = Trail::new();
         let mut scan = self.source();
         let old_h = self.threshold();
@@ -83,13 +74,13 @@ pub(crate) trait CopierTarget
 
                             let threshold = self.threshold();
                             self[scan] = HeapCellValue::Addr(Addr::Lis(threshold));
-                            
+
                             let hcv = self[a].clone();
-                            self.push(hcv.clone());                                                       
-                            
+                            self.push(hcv.clone());
+
                             let ra = hcv.as_addr(threshold);
                             let rd = self.store(self.deref(ra));
-                            
+
                             match rd.clone() {
                                 Addr::HeapCell(hc) if hc >= old_h => {
                                     self[threshold] = HeapCellValue::Addr(rd);
@@ -108,7 +99,7 @@ pub(crate) trait CopierTarget
                                     trail.push((Ref::HeapCell(a), self[a].clone()));
                                     self[a] = HeapCellValue::Addr(Addr::Lis(threshold))
                                 }
-                            };                                                        
+                            };
 
                             let hcv = self[a+1].clone();
                             self.push(hcv);
index 1428edf32b971df778c12582bd4e70335940705c..30d78a961b0a34b92736ab3c489c9b904bdcdab3 100644 (file)
@@ -60,10 +60,8 @@ impl<'a> HCPreOrderIterator<'a> {
 
                 da
             },
-            Addr::HeapCell(_) | Addr::StackCell(_, _) =>
-                da,
-            Addr::Str(s) =>
-                self.follow_heap(s) // record terms of structure.
+            Addr::HeapCell(_) | Addr::StackCell(_, _) => da,
+            Addr::Str(s) => self.follow_heap(s) // record terms of structure.
         }
     }
 }