]> Repositorios git - scryer-prolog.git/commitdiff
fix #255 (I think?)
authorMark Thom <[email protected]>
Fri, 21 Feb 2020 08:02:52 +0000 (01:02 -0700)
committerMark Thom <[email protected]>
Fri, 21 Feb 2020 08:02:52 +0000 (01:02 -0700)
src/prolog/clause_types.rs
src/prolog/machine/attributed_variables.pl
src/prolog/machine/attributed_variables.rs
src/prolog/machine/machine_state_impl.rs
src/prolog/machine/system_calls.rs

index 6f7a9187aaf5b7e061fcf0422e4e3e291c6b3b52..bbb9accc1860ae3fc362ddc59af84112b11c4166 100644 (file)
@@ -164,7 +164,6 @@ pub enum SystemClauseType {
     CallContinuation,
     CharCode,
     CharsToNumber,
-    ClearAttrVarBindings,
     ClearAttributeGoals,
     CloneAttributeGoals,
     CodesToNumber,
@@ -295,7 +294,6 @@ impl SystemClauseType {
            &SystemClauseType::REPL(REPLCodePtr::UseQualifiedModuleFromFile) => {
                clause_name!("$use_qualified_module_from_file")
            }
-            &SystemClauseType::ClearAttrVarBindings => clause_name!("$clear_attr_var_bindings"),
             &SystemClauseType::CopyToLiftedHeap => clause_name!("$copy_to_lh"),
             &SystemClauseType::DeleteAttribute => clause_name!("$del_attr_non_head"),
             &SystemClauseType::DeleteHeadAttribute => clause_name!("$del_attr_head"),
@@ -424,7 +422,6 @@ impl SystemClauseType {
             ("$call_continuation", 1) => Some(SystemClauseType::CallContinuation),
             ("$char_code", 2) => Some(SystemClauseType::CharCode),
             ("$chars_to_number", 2) => Some(SystemClauseType::CharsToNumber),
-            ("$clear_attr_var_bindings", 0) => Some(SystemClauseType::ClearAttrVarBindings),
             ("$clear_attribute_goals", 0) => Some(SystemClauseType::ClearAttributeGoals),
             ("$clone_attribute_goals", 1) => Some(SystemClauseType::CloneAttributeGoals),
             ("$codes_to_number", 2) => Some(SystemClauseType::CodesToNumber),
index 01ea8b7d0cd5ee6b53175801e6c153e66e18a8b2..2a18d639594742d1d07085dc4d25d57b275c29af 100644 (file)
@@ -1,6 +1,5 @@
 driver(Vars, Values) :-
     iterate(Vars, Values, ListOfListsOfGoalLists),
-    '$clear_attr_var_bindings',
     !,
     call_goals(ListOfListsOfGoalLists),
     '$return_from_verify_attr'.
@@ -17,13 +16,6 @@ gather_modules([Attr|Attrs], [Module|Modules]) :-
     '$module_of'(Module, Attr),  % write the owning module of Attr to Module.
     gather_modules(Attrs, Modules).
 
-verify_attrs([Module|Modules], Var, Value, [Goals|ListOfGoalLists]) :-
-    catch(Module:verify_attributes(Var, Value, Goals),
-          error(evaluation_error((Module:verify_attributes)/3), verify_attributes/3),
-          Goals = []),
-    verify_attrs(Modules, Var, Value, ListOfGoalLists).
-verify_attrs([], _, _, []).
-
 call_verify_attributes(Attrs, _, _, []) :-
     var(Attrs), !.
 call_verify_attributes([], _, _, []).
@@ -32,6 +24,13 @@ call_verify_attributes([Attr|Attrs], Var, Value, ListOfGoalLists) :-
     sort(Modules0, Modules),    
     verify_attrs(Modules, Var, Value, ListOfGoalLists).
 
+verify_attrs([Module|Modules], Var, Value, [Goals|ListOfGoalLists]) :-
+    catch(Module:verify_attributes(Var, Value, Goals),
+          error(evaluation_error((Module:verify_attributes)/3), verify_attributes/3),
+          Goals = []),    
+    verify_attrs(Modules, Var, Value, ListOfGoalLists).
+verify_attrs([], _, _, []).
+
 call_goals([ListOfGoalLists | ListsCubed]) :-
     call_goals_0(ListOfGoalLists),
     call_goals(ListsCubed).
index 6c2dc4c196d30be20d4af1de3501c41a14758323..44ebbe0b3ac5b3576fba429c76a846f21a2fb2ee 100644 (file)
@@ -73,11 +73,10 @@ impl MachineState {
         let iter = self
             .attr_var_init
             .bindings
-            .iter()
-            .map(|(_, ref addr)| addr.clone());
+            .drain(0 ..)
+            .map(|(_, addr)| addr);
 
         let value_list_addr = Addr::HeapCell(self.heap.to_list(iter));
-
         (var_list_addr, value_list_addr)
     }
 
index d93144a12727db60d536a306521c5290f3767cb6..82c0c4f2daa224c6a6b7c7624715ada405d6c745 100644 (file)
@@ -191,7 +191,8 @@ impl MachineState {
         self.trail(TrailRef::from(Ref::PStrTail(h, pstr_len)));
     }
 
-    pub(super) fn bind(&mut self, r1: Ref, a2: Addr) {
+    pub(super)
+    fn bind(&mut self, r1: Ref, a2: Addr) {
         let t1 = self.store(r1.as_addr());
         let t2 = self.store(a2.clone());
 
index 78677b948cb3d3890b1a52eac5c73c547d1f23a7..7a94db03ab38fe85c5f75827f5353af6986718a4 100644 (file)
@@ -1973,9 +1973,6 @@ impl MachineState {
                     }
                 };
             }
-            &SystemClauseType::ClearAttrVarBindings => {
-                self.attr_var_init.bindings.clear();
-            }
             &SystemClauseType::RedoAttrVarBinding => {
                 let var = self.store(self.deref(self[temp_v!(1)].clone()));
                 let value = self.store(self.deref(self[temp_v!(2)].clone()));