]> Repositorios git - scryer-prolog.git/commitdiff
detect attributed variables by properly detecting them in copy_term/2
authorMark Thom <[email protected]>
Tue, 30 Nov 2021 02:22:26 +0000 (19:22 -0700)
committerMark Thom <[email protected]>
Fri, 7 Jan 2022 04:44:41 +0000 (21:44 -0700)
src/machine/attributed_variables.rs
src/machine/copier.rs
src/types.rs

index 30ec9a8c9bbca922101b7e84562e02331cf1b695..568978d8891ac07762c24bf669f5d000425dccd6 100644 (file)
@@ -143,6 +143,8 @@ impl MachineState {
                         continue;
                     }
 
+                    let value = unmark_cell_bits!(value);
+
                     seen_vars.push(value);
                     seen_set.insert(h);
 
index bab1d110b12465ed2249dd4dea75acdb240d25d0..f5417e5320ffe50a383fe91e4c804c951f44a75e 100644 (file)
@@ -166,8 +166,7 @@ impl<T: CopierTarget> CopyTermState<T> {
                 self.trail.push((Ref::attr_var(h), attr_var_as_cell!(h)));
 
                 if let AttrVarPolicy::DeepCopy = self.attr_var_policy {
-                    self.target
-                        .push(attr_var_as_cell!(threshold));
+                    self.target.push(attr_var_as_cell!(threshold));
 
                     let list_val = self.target[h + 1];
                     self.target.push(list_val);
@@ -195,58 +194,14 @@ impl<T: CopierTarget> CopyTermState<T> {
             _ => {}
         );
 
-        if addr == ra {
-            self.reinstantiate_var(addr, self.scan);
+        if rd == ra {
+            self.reinstantiate_var(ra, self.scan);
             self.scan += 1;
         } else {
             *self.value_at_scan() = ra;
-            // self.copy_compound(rd, ra);
         }
     }
 
-    /*
-    fn copy_compound(&mut self, rd: HeapCellValue, ra: HeapCellValue) {
-        let h = rd.get_value();
-        let trail_item = self.target[h];
-        let threshold = self.target.threshold();
-
-        self.trail.push((Ref::heap_cell(h), trail_item));
-        self.target[self.scan].set_value(threshold);
-
-        read_heap_cell!(ra,
-            (HeapCellValueTag::Atom, (_name, arity)) => {
-                self.target.push(ra);
-
-                for i in 0..arity {
-                    self.target.push(self.target[h + 1 + i]);
-                }
-
-                self.target[h] = str_loc_as_cell!(self.scan + 1);
-            }
-            (HeapCellValueTag::PStr | HeapCellValueTag::PStrOffset) => {
-                self.target.push(ra);
-                self.target.push(self.target[h + 1]);
-
-                self.target[h] = pstr_loc_as_cell!(self.scan + 1);
-            }
-            (HeapCellValueTag::CStr, cstr_atom) => {
-                self.target[h] = atom_as_cstr_cell!(cstr_atom);
-            }
-            (HeapCellValueTag::Str, s) => {
-                self.copy_structure(s);
-                return;
-            }
-            _ => {
-                *self.value_at_scan() = rd;
-                self.trail.pop();
-                return;
-            }
-        );
-
-        self.scan += 1;
-    }
-    */
-
     fn copy_structure(&mut self, addr: usize) {
         read_heap_cell!(self.target[addr],
             (HeapCellValueTag::Atom, (name, arity)) => {
index 57a6c5a31937a5c0ec2097f0434c8bf992cfc184..b0339a1a59dcd4dba13f948533cf1c1ed72f4d2e 100644 (file)
@@ -221,9 +221,9 @@ impl TrailEntry {
     #[inline(always)]
     pub(crate) fn get_tag(self) -> TrailEntryTag {
         match self.tag_or_err() {
-           Ok(tag) => tag,
-           Err(_) => TrailEntryTag::TrailedAttachedValue,
-       }
+               Ok(tag) => tag,
+               Err(_) => TrailEntryTag::TrailedAttachedValue,
+           }
     }
 
     #[inline]