correct attribute_goals/2 bug, add freeze/2, update README

This commit is contained in:
Mark Thom
2019-02-15 20:44:15 -07:00
parent 3fb91fe0c8
commit 74a0f8b899
4 changed files with 16 additions and 14 deletions

View File

@@ -48,6 +48,8 @@ Extend rusty-wam to include the following, among other features:
* Clause creation and destruction (`asserta/1`, `assertz/1`, * Clause creation and destruction (`asserta/1`, `assertz/1`,
`retract/1`, `abolish/1`) with logical update semantics. `retract/1`, `abolish/1`) with logical update semantics.
* Streams and predicates for stream control. * Streams and predicates for stream control.
* An incremental compacting garbage collector satisfying the five
properties of "Precise Garbage Collection in Prolog."
* Mode declarations. * Mode declarations.
* Extensions for clp(FD). * 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 3. Add support for shift/reset delimited continuations, see "Delimited
Continuations for Prolog." Continuations for Prolog."
4. Add an incremental compacting garbage collector for the heap. 4. Add concurrent tables to manage shared references to atoms and
5. Add concurrent tables to manage shared references to atoms and
strings. 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 ## Installing rusty-wam
@@ -151,6 +151,7 @@ The following predicates are built-in to rusty-wam.
* `expand_term/2` * `expand_term/2`
* `false/0` * `false/0`
* `float/1` * `float/1`
* `freeze/2`
* `functor/3` * `functor/3`
* `goal_expansion/2` * `goal_expansion/2`
* `ground/1` * `ground/1`

View File

@@ -36,8 +36,7 @@ verify_attributes(Var, Value, Goals) :-
% suggestions for improvement. % suggestions for improvement.
dif(X, Y) :- X \== Y, 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(XVars, X, Y),
dif_set_variables(YVars, X, Y) dif_set_variables(YVars, X, Y)
). ).

View File

@@ -83,14 +83,14 @@ impl MachineState {
self[temp_v!(2)] = value_list_addr; 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(); 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); let addr = self.heap[i].as_addr(i);
match self.store(self.deref(addr)) { match addr {
Addr::AttrVar(h) => { Addr::AttrVar(h) if i == h => {
attr_vars.insert(Addr::AttrVar(h)); attr_vars.insert(Addr::AttrVar(h));
}, },
_ => {} _ => {}
@@ -162,13 +162,13 @@ impl MachineState {
if attr_goals.is_empty() { if attr_goals.is_empty() {
return; return;
} }
let mut output = PrinterOutputter::new(); let mut output = PrinterOutputter::new();
for goal_addr in attr_goals { for goal_addr in attr_goals {
let mut printer = HCPrinter::from_heap_locs(&self, output, var_dict); let mut printer = HCPrinter::from_heap_locs(&self, output, var_dict);
printer.see_all_locs(); printer.see_all_locs();
printer.numbervars = false; printer.numbervars = false;
printer.quoted = true; printer.quoted = true;
@@ -179,7 +179,7 @@ impl MachineState {
// cut trailing ", " // cut trailing ", "
let output_len = output.len(); let output_len = output.len();
output.truncate(output_len - 2); output.truncate(output_len - 2);
println!("\r\n{}\r", output.result()); println!("\r\n{}\r", output.result());
} }
} }

View File

@@ -320,6 +320,7 @@ static TERMS: &str = include_str!("../lib/terms.pl");
static DCGS: &str = include_str!("../lib/dcgs.pl"); static DCGS: &str = include_str!("../lib/dcgs.pl");
static ATTS: &str = include_str!("../lib/atts.pl"); static ATTS: &str = include_str!("../lib/atts.pl");
static DIF: &str = include_str!("../lib/dif.pl"); static DIF: &str = include_str!("../lib/dif.pl");
static FREEZE: &str = include_str!("../lib/freeze.pl");
impl Machine { impl Machine {
fn compile_special_forms(&mut self) { fn compile_special_forms(&mut self) {
@@ -349,6 +350,7 @@ impl Machine {
compile_user_module(self, DCGS.as_bytes()); compile_user_module(self, DCGS.as_bytes());
compile_user_module(self, ATTS.as_bytes()); compile_user_module(self, ATTS.as_bytes());
compile_user_module(self, DIF.as_bytes()); compile_user_module(self, DIF.as_bytes());
compile_user_module(self, FREEZE.as_bytes());
} }
pub fn new() -> Self { pub fn new() -> Self {