]> Repositorios git - scryer-prolog.git/commitdiff
correct attribute_goals/2 bug, add freeze/2, update README
authorMark Thom <[email protected]>
Sat, 16 Feb 2019 03:44:15 +0000 (20:44 -0700)
committerMark Thom <[email protected]>
Sat, 16 Feb 2019 03:44:15 +0000 (20:44 -0700)
README.md
src/prolog/lib/dif.pl
src/prolog/machine/attributed_variables.rs
src/prolog/machine/mod.rs

index 356548b8b14c687fb9d65a37faf15e0082baa899..3e3e0e4adb0e41357e222a9607c8de469a7186f1 100644 (file)
--- a/README.md
+++ b/README.md
@@ -48,6 +48,8 @@ Extend rusty-wam to include the following, among other features:
 * Clause creation and destruction (`asserta/1`, `assertz/1`,
   `retract/1`, `abolish/1`) with logical update semantics.
 * Streams and predicates for stream control.
+* An incremental compacting garbage collector satisfying the five
+  properties of "Precise Garbage Collection in Prolog."
 * Mode declarations.
 * Extensions for clp(FD).
 
@@ -77,14 +79,12 @@ Gustafson's book "The End of Error."
 3. Add support for shift/reset delimited continuations, see "Delimited
 Continuations for Prolog."
 
-4. Add an incremental compacting garbage collector for the heap.
-
-5. Add concurrent tables to manage shared references to atoms and
+4. Add concurrent tables to manage shared references to atoms and
 strings.
 
-6. Add optional SLG resolution for fast memoization of predicates.
+5. Add optional SLG resolution for fast memoization of predicates.
 
-7. Add some form of JIT predicate indexing.
+6. Add some form of JIT predicate indexing.
 
 ## Installing rusty-wam
 
@@ -151,6 +151,7 @@ The following predicates are built-in to rusty-wam.
 * `expand_term/2`
 * `false/0`
 * `float/1`
+* `freeze/2`
 * `functor/3`
 * `goal_expansion/2`
 * `ground/1`
index c2097fd4d478e9b096f7550ebd0d6adb57da52fd..82aa5f1c054e50d7af4b0e19eabd2541dbbcf0f2 100644 (file)
@@ -36,8 +36,7 @@ verify_attributes(Var, Value, Goals) :-
 % suggestions for improvement.
 
 dif(X, Y) :- X \== Y,
-             (   X \= Y -> true
-             ;   term_variables(X, XVars), term_variables(Y, YVars),
+             (   term_variables(X, XVars), term_variables(Y, YVars),
                 dif_set_variables(XVars, X, Y),
                 dif_set_variables(YVars, X, Y)
             ).
index bd7ec478feb516420e38e1eacc0742df9e3d5b9b..b8216e2efc8dd48170a572bfa4573f085581efd1 100644 (file)
@@ -83,14 +83,14 @@ impl MachineState {
         self[temp_v!(2)] = value_list_addr;
     }
 
-    fn gather_attr_vars_created_since(&mut self, h: usize) -> IntoIter<Addr> {
+    fn gather_attr_vars_created_since(&self, h: usize) -> IntoIter<Addr> {
         let mut attr_vars = HashSet::new();
 
-        for i in h .. self.heap.len() {
+        for i in h .. self.heap.h {
             let addr = self.heap[i].as_addr(i);
 
-            match self.store(self.deref(addr)) {
-                Addr::AttrVar(h) => {
+            match addr {
+                Addr::AttrVar(h) if i == h => {
                     attr_vars.insert(Addr::AttrVar(h));
                 },
                 _ => {}
@@ -162,13 +162,13 @@ impl MachineState {
         if attr_goals.is_empty() {
             return;
         }
-        
+
         let mut output = PrinterOutputter::new();
 
         for goal_addr in attr_goals {
             let mut printer = HCPrinter::from_heap_locs(&self, output, var_dict);
             printer.see_all_locs();
-            
+
             printer.numbervars = false;
             printer.quoted = true;
 
@@ -179,7 +179,7 @@ impl MachineState {
         // cut trailing ", "
         let output_len = output.len();
         output.truncate(output_len - 2);
-        
+
         println!("\r\n{}\r", output.result());
     }
 }
index 1b6ac2a58380036c78ecda8800f27b4ce4720532..54f27231e426ad4f28f3a88fc9d3d52a92347c44 100644 (file)
@@ -320,6 +320,7 @@ static TERMS: &str    = include_str!("../lib/terms.pl");
 static DCGS: &str     = include_str!("../lib/dcgs.pl");
 static ATTS: &str     = include_str!("../lib/atts.pl");
 static DIF: &str      = include_str!("../lib/dif.pl");
+static FREEZE: &str   = include_str!("../lib/freeze.pl");
 
 impl Machine {
     fn compile_special_forms(&mut self) {
@@ -349,6 +350,7 @@ impl Machine {
         compile_user_module(self, DCGS.as_bytes());
         compile_user_module(self, ATTS.as_bytes());
         compile_user_module(self, DIF.as_bytes());
+        compile_user_module(self, FREEZE.as_bytes());
     }
 
     pub fn new() -> Self {