From 2dc7832f595a4b774ce7b979ba71ab707dc7b7ef Mon Sep 17 00:00:00 2001 From: Mark Thom Date: Sun, 10 Dec 2017 13:55:49 -0700 Subject: [PATCH] update README, heap ADT --- README.md | 17 +++++++++++++++++ src/prolog/ast.rs | 17 ++++++----------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 1e0ff29e..ad634f73 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,23 @@ IR to get JIT-compiled and -executed Prolog programs. It's my hope to use rusty-wam as the logic engine of a low level (and ideally, very fast) [Shen](http://shenlanguage.org) implementation. +## Nice to have features + +There are no current plans to implement any of these, but they might be +nice to have in the future. They'd make a good project for anyone wanting +to contribute code to rusty-wam. + +1. Add the global analysis techniques of Peter van Roy's thesis, "Can +Logic Programming Execute as Fast as Imperative Programming?" + +2. Add support for unum representation and arithmetic, as described in 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 the heap. + ## Built-in predicates The following predicates are built-in to rusty-wam. diff --git a/src/prolog/ast.rs b/src/prolog/ast.rs index a8c9f376..bb24187e 100644 --- a/src/prolog/ast.rs +++ b/src/prolog/ast.rs @@ -968,19 +968,13 @@ impl Heap { } pub fn push(&mut self, val: HeapCellValue) { - let h = self.h; - - if h < self.heap.len() { - self.heap[h] = val; - } else { - self.heap.push(val); - } - + self.heap.push(val); self.h += 1; } pub fn truncate(&mut self, h: usize) { self.h = h; + self.heap.truncate(h); } pub fn len(&self) -> usize { @@ -988,9 +982,10 @@ impl Heap { } pub fn append(&mut self, vals: Vec) { - for val in vals.into_iter() { - self.push(val); - } + let n = vals.len(); + + self.heap.extend(vals.into_iter()); + self.h += n; } pub fn clear(&mut self) { -- 2.54.0