do not unify partial strings unless they coincide in memory

This commit is contained in:
Mark Thom
2018-09-03 00:20:01 -06:00
parent c5fd13dfa0
commit 3960ea4f06
2 changed files with 11 additions and 8 deletions

View File

@@ -254,7 +254,7 @@ impl MachineState {
return true;
}
} else if s2.is_expandable() {
} else if s2.is_expandable() {
pdl.push(Addr::Con(Constant::String(s2.push_char(c1))));
pdl.push(Addr::Con(Constant::String(s1.tail())));
@@ -264,12 +264,12 @@ impl MachineState {
if let Some(c) = s2.head() {
pdl.push(Addr::Con(Constant::String(s1.push_char(c))));
pdl.push(Addr::Con(Constant::String(s2.tail())));
} else if !s2.is_expandable() {
} else if s2.is_expandable() {
return s1 == s2;
} else {
s1.set_non_expandable();
}/*else {
//TODO: unify the tails of s1 and s2? I guess?
}*/
}
return true;
} else if s2.head().is_none() {
s2.set_non_expandable();
@@ -1445,7 +1445,7 @@ impl MachineState {
false
}
pub(super) fn compare_term_test(&self, a1: &Addr, a2: &Addr) -> Ordering {
let iter = self.zipped_acyclic_pre_order_iter(a1.clone(), a2.clone());
@@ -1526,7 +1526,7 @@ impl MachineState {
HeapCellValue::Addr(Addr::Con(Constant::Number(_)))) =>
return Ordering::Greater,
(HeapCellValue::Addr(Addr::Con(Constant::String(s1))),
HeapCellValue::Addr(Addr::Con(Constant::String(s2)))) =>
HeapCellValue::Addr(Addr::Con(Constant::String(s2)))) =>
return s1.cmp(&s2),
(HeapCellValue::Addr(Addr::Con(Constant::String(_))), _) =>
return Ordering::Less,

View File

@@ -1881,6 +1881,9 @@ fn test_queries_on_string_lists()
assert_prolog_success!(&mut wam, "?- partial_string(\"abc\", X).",
[["X = [a, b, c | _]"]]);
assert_prolog_failure!(&mut wam, "?- partial_string(\"abc\", X), partial_string(\"abc\", Y), matcher(X, V),
matcher(Y, Z), V = Z.");
submit(&mut wam, "matcher([a, b, c | X], X).");
assert_prolog_success!(&mut wam, "?- partial_string(\"abc\", X), matcher(X, Y).",