From be3cdcd71ae43a6e8e763233307b8583054e90e7 Mon Sep 17 00:00:00 2001 From: Mark Thom Date: Fri, 21 Feb 2020 01:02:52 -0700 Subject: [PATCH] fix #255 (I think?) --- src/prolog/clause_types.rs | 3 --- src/prolog/machine/attributed_variables.pl | 15 +++++++-------- src/prolog/machine/attributed_variables.rs | 5 ++--- src/prolog/machine/machine_state_impl.rs | 3 ++- src/prolog/machine/system_calls.rs | 3 --- 5 files changed, 11 insertions(+), 18 deletions(-) diff --git a/src/prolog/clause_types.rs b/src/prolog/clause_types.rs index 6f7a9187..bbb9accc 100644 --- a/src/prolog/clause_types.rs +++ b/src/prolog/clause_types.rs @@ -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), diff --git a/src/prolog/machine/attributed_variables.pl b/src/prolog/machine/attributed_variables.pl index 01ea8b7d..2a18d639 100644 --- a/src/prolog/machine/attributed_variables.pl +++ b/src/prolog/machine/attributed_variables.pl @@ -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). diff --git a/src/prolog/machine/attributed_variables.rs b/src/prolog/machine/attributed_variables.rs index 6c2dc4c1..44ebbe0b 100644 --- a/src/prolog/machine/attributed_variables.rs +++ b/src/prolog/machine/attributed_variables.rs @@ -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) } diff --git a/src/prolog/machine/machine_state_impl.rs b/src/prolog/machine/machine_state_impl.rs index d93144a1..82c0c4f2 100644 --- a/src/prolog/machine/machine_state_impl.rs +++ b/src/prolog/machine/machine_state_impl.rs @@ -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()); diff --git a/src/prolog/machine/system_calls.rs b/src/prolog/machine/system_calls.rs index 78677b94..7a94db03 100644 --- a/src/prolog/machine/system_calls.rs +++ b/src/prolog/machine/system_calls.rs @@ -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())); -- 2.54.0