change project_attributes to use attribute vars queue
This commit is contained in:
@@ -2,7 +2,7 @@ use prolog::heap_iter::*;
|
|||||||
use prolog::machine::*;
|
use prolog::machine::*;
|
||||||
|
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::collections::hash_set::IntoIter;
|
use std::vec::IntoIter;
|
||||||
|
|
||||||
pub static VERIFY_ATTRS: &str = include_str!("attributed_variables.pl");
|
pub static VERIFY_ATTRS: &str = include_str!("attributed_variables.pl");
|
||||||
pub static PROJECT_ATTRS: &str = include_str!("project_attributes.pl");
|
pub static PROJECT_ATTRS: &str = include_str!("project_attributes.pl");
|
||||||
@@ -85,20 +85,19 @@ impl MachineState {
|
|||||||
self[temp_v!(2)] = value_list_addr;
|
self[temp_v!(2)] = value_list_addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gather_attr_vars_created_since(&self, h: usize) -> IntoIter<Addr> {
|
pub(super)
|
||||||
let mut attr_vars = HashSet::new();
|
fn gather_attr_vars_created_since(&self, b: usize) -> IntoIter<Addr>
|
||||||
|
{
|
||||||
|
let mut attr_vars: Vec<_> = self.attr_var_init.attr_var_queue[b ..]
|
||||||
|
.iter().filter_map(|h|
|
||||||
|
match self.store(self.deref(Addr::HeapCell(*h))) {
|
||||||
|
Addr::AttrVar(h) => Some(Addr::AttrVar(h)),
|
||||||
|
_ => None
|
||||||
|
}).collect();
|
||||||
|
|
||||||
for i in h .. self.heap.h {
|
attr_vars.sort_unstable_by(|a1, a2| self.compare_term_test(a1, a2));
|
||||||
let addr = self.heap[i].as_addr(i);
|
|
||||||
|
|
||||||
match addr {
|
|
||||||
Addr::AttrVar(h) if i == h => {
|
|
||||||
attr_vars.insert(Addr::AttrVar(h));
|
|
||||||
},
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
self.term_dedup(&mut attr_vars);
|
||||||
attr_vars.into_iter()
|
attr_vars.into_iter()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -316,20 +316,12 @@ impl MachineState {
|
|||||||
|
|
||||||
match self.store(self.deref(addr)) {
|
match self.store(self.deref(addr)) {
|
||||||
Addr::Con(Constant::Usize(b)) => {
|
Addr::Con(Constant::Usize(b)) => {
|
||||||
let mut attr_vars: Vec<_> = self.attr_var_init.attr_var_queue[b ..]
|
let iter = self.gather_attr_vars_created_since(b);
|
||||||
.iter().filter_map(|h|
|
|
||||||
match self.store(self.deref(Addr::HeapCell(*h))) {
|
let var_list_addr = Addr::HeapCell(self.heap.to_list(iter));
|
||||||
Addr::AttrVar(h) => Some(Addr::AttrVar(h)),
|
|
||||||
_ => None
|
|
||||||
}).collect();
|
|
||||||
|
|
||||||
attr_vars.sort_unstable_by(|a1, a2| self.compare_term_test(a1, a2));
|
|
||||||
|
|
||||||
self.term_dedup(&mut attr_vars);
|
|
||||||
let var_list_addr = Addr::HeapCell(self.heap.to_list(attr_vars.into_iter()));
|
|
||||||
|
|
||||||
let list_addr = self[temp_v!(2)].clone();
|
let list_addr = self[temp_v!(2)].clone();
|
||||||
self.unify(var_list_addr, list_addr);
|
|
||||||
|
self.unify(var_list_addr, list_addr);
|
||||||
},
|
},
|
||||||
_ => self.fail = true
|
_ => self.fail = true
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user