]> Repositorios git - scryer-prolog.git/commitdiff
reset attributed variable state between toplevel queries (#242)
authorMark Thom <[email protected]>
Fri, 29 Nov 2019 02:08:08 +0000 (19:08 -0700)
committerMark Thom <[email protected]>
Fri, 29 Nov 2019 02:08:08 +0000 (19:08 -0700)
src/prolog/clause_types.rs
src/prolog/machine/attributed_variables.rs
src/prolog/machine/system_calls.rs
src/prolog/toplevel.pl

index bf17531cf9b8583da444d974c3c5f89021310e80..82bd8cde6076d538af3a6d21e654182a05e194e0 100644 (file)
@@ -179,6 +179,7 @@ pub enum SystemClauseType {
     FetchGlobalVar,
     FetchGlobalVarWithOffset,
     GetChar,
+    ResetAttrVarState,
     TruncateIfNoLiftedHeapGrowthDiff,
     TruncateIfNoLiftedHeapGrowth,
     GetAttributedVariableList,
@@ -289,6 +290,7 @@ impl SystemClauseType {
                 clause_name!("$fetch_global_var_with_offset")
             }
             &SystemClauseType::GetChar => clause_name!("$get_char"),
+            &SystemClauseType::ResetAttrVarState => clause_name!("$reset_attr_var_state"),
             &SystemClauseType::TruncateIfNoLiftedHeapGrowth => {
                 clause_name!("$truncate_if_no_lh_growth")
             }
@@ -408,6 +410,7 @@ impl SystemClauseType {
             ("$fetch_global_var", 2) => Some(SystemClauseType::FetchGlobalVar),
             ("$fetch_global_var_with_offset", 3) => Some(SystemClauseType::FetchGlobalVarWithOffset),
             ("$get_char", 1) => Some(SystemClauseType::GetChar),
+            ("$reset_attr_var_state", 0) => Some(SystemClauseType::ResetAttrVarState),
             ("$truncate_if_no_lh_growth", 1) => {
                 Some(SystemClauseType::TruncateIfNoLiftedHeapGrowth)
             }
index 992ba98d66eefe0909211fe2f4553c90a9dc75df..50a101b90e82f78f3de7b6ce9a849cf926ffe9c2 100644 (file)
@@ -32,9 +32,9 @@ impl AttrVarInitializer {
 
     #[inline]
     pub(super) fn reset(&mut self) {
+       self.attribute_goals.clear();
         self.attr_var_queue.clear();
         self.bindings.clear();
-       self.attribute_goals.clear();
     }
 }
 
index fd3e31a582e4b17ee338a65324a73cc5bf5f5717..e168849b896219cf62b38e0da1d7cfd557bb1e2b 100644 (file)
@@ -1680,6 +1680,9 @@ impl MachineState {
                     }
                 };
             },
+            &SystemClauseType::ResetAttrVarState => {
+                self.attr_var_init.reset();
+            }
             &SystemClauseType::RemoveCallPolicyCheck => {
                 let restore_default = match call_policy.downcast_mut::<CWILCallPolicy>().ok() {
                     Some(call_policy) => {
index 634335544b4fbbc245deb383015e215d1250eafc..51eb93faefab620ebf5f420688051d6b76907d97 100644 (file)
@@ -44,7 +44,8 @@
     ),
     (  '$get_b_value'(B), call(Term), '$write_eqs_and_read_input'(B, VarList), !
     ;  write('false.'), nl
-    ).
+    ),
+    '$reset_attr_var_state'.
 
 '$needs_bracketing'(Value, Op) :-
     catch((functor(Value, F, _),