]> Repositorios git - scryer-prolog.git/commitdiff
record names of variables at root in write_term_to_heap (#487)
authorMark Thom <[email protected]>
Mon, 11 May 2020 03:48:38 +0000 (21:48 -0600)
committerMark Thom <[email protected]>
Mon, 11 May 2020 03:48:38 +0000 (21:48 -0600)
src/prolog/read.rs

index 29b37fcbdb22b9b7b0913e4137b36b66406ca146..4751759ef40dce68975437d8ac28c51c9a1d0c50 100644 (file)
@@ -267,11 +267,15 @@ impl<'a> TermWriter<'a> {
                         continue;
                     }
                 }
-                &TermRef::AnonVar(Level::Root) | &TermRef::Constant(Level::Root, ..) |
-                &TermRef::Var(Level::Root, ..) => {
+                &TermRef::AnonVar(Level::Root) | &TermRef::Constant(Level::Root, ..) => {
                     let addr = self.term_as_addr(&term, h);
                     self.machine_st.heap.push(HeapCellValue::Addr(addr));
                 }
+                &TermRef::Var(Level::Root, _, ref var) => {
+                    let addr = self.term_as_addr(&term, h);
+                    self.var_dict.insert(var.clone(), Addr::HeapCell(h));
+                    self.machine_st.heap.push(HeapCellValue::Addr(addr));
+                }
                 &TermRef::AnonVar(_) => {
                     if let Some((arity, site_h)) = self.queue.pop_front() {
                         if arity > 1 {