reset attributed variable state between toplevel queries (#242)

This commit is contained in:
Mark Thom
2019-11-28 19:08:08 -07:00
parent 7eb0de7f52
commit 335202b9d9
4 changed files with 9 additions and 2 deletions

View File

@@ -179,6 +179,7 @@ pub enum SystemClauseType {
FetchGlobalVar, FetchGlobalVar,
FetchGlobalVarWithOffset, FetchGlobalVarWithOffset,
GetChar, GetChar,
ResetAttrVarState,
TruncateIfNoLiftedHeapGrowthDiff, TruncateIfNoLiftedHeapGrowthDiff,
TruncateIfNoLiftedHeapGrowth, TruncateIfNoLiftedHeapGrowth,
GetAttributedVariableList, GetAttributedVariableList,
@@ -289,6 +290,7 @@ impl SystemClauseType {
clause_name!("$fetch_global_var_with_offset") clause_name!("$fetch_global_var_with_offset")
} }
&SystemClauseType::GetChar => clause_name!("$get_char"), &SystemClauseType::GetChar => clause_name!("$get_char"),
&SystemClauseType::ResetAttrVarState => clause_name!("$reset_attr_var_state"),
&SystemClauseType::TruncateIfNoLiftedHeapGrowth => { &SystemClauseType::TruncateIfNoLiftedHeapGrowth => {
clause_name!("$truncate_if_no_lh_growth") clause_name!("$truncate_if_no_lh_growth")
} }
@@ -408,6 +410,7 @@ impl SystemClauseType {
("$fetch_global_var", 2) => Some(SystemClauseType::FetchGlobalVar), ("$fetch_global_var", 2) => Some(SystemClauseType::FetchGlobalVar),
("$fetch_global_var_with_offset", 3) => Some(SystemClauseType::FetchGlobalVarWithOffset), ("$fetch_global_var_with_offset", 3) => Some(SystemClauseType::FetchGlobalVarWithOffset),
("$get_char", 1) => Some(SystemClauseType::GetChar), ("$get_char", 1) => Some(SystemClauseType::GetChar),
("$reset_attr_var_state", 0) => Some(SystemClauseType::ResetAttrVarState),
("$truncate_if_no_lh_growth", 1) => { ("$truncate_if_no_lh_growth", 1) => {
Some(SystemClauseType::TruncateIfNoLiftedHeapGrowth) Some(SystemClauseType::TruncateIfNoLiftedHeapGrowth)
} }

View File

@@ -32,9 +32,9 @@ impl AttrVarInitializer {
#[inline] #[inline]
pub(super) fn reset(&mut self) { pub(super) fn reset(&mut self) {
self.attribute_goals.clear();
self.attr_var_queue.clear(); self.attr_var_queue.clear();
self.bindings.clear(); self.bindings.clear();
self.attribute_goals.clear();
} }
} }

View File

@@ -1680,6 +1680,9 @@ impl MachineState {
} }
}; };
}, },
&SystemClauseType::ResetAttrVarState => {
self.attr_var_init.reset();
}
&SystemClauseType::RemoveCallPolicyCheck => { &SystemClauseType::RemoveCallPolicyCheck => {
let restore_default = match call_policy.downcast_mut::<CWILCallPolicy>().ok() { let restore_default = match call_policy.downcast_mut::<CWILCallPolicy>().ok() {
Some(call_policy) => { Some(call_policy) => {

View File

@@ -44,7 +44,8 @@
), ),
( '$get_b_value'(B), call(Term), '$write_eqs_and_read_input'(B, VarList), ! ( '$get_b_value'(B), call(Term), '$write_eqs_and_read_input'(B, VarList), !
; write('false.'), nl ; write('false.'), nl
). ),
'$reset_attr_var_state'.
'$needs_bracketing'(Value, Op) :- '$needs_bracketing'(Value, Op) :-
catch((functor(Value, F, _), catch((functor(Value, F, _),