From: Mark Thom Date: Mon, 6 Jun 2022 02:53:07 +0000 (-0600) Subject: replace call with $call in more meta-predicates X-Git-Tag: v0.9.1~10 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=336311ecc86376268aca3a87c0568c0e15a1c96c;p=scryer-prolog.git replace call with $call in more meta-predicates --- diff --git a/src/lib/builtins.pl b/src/lib/builtins.pl index 9907b85c..3106a7b0 100644 --- a/src/lib/builtins.pl +++ b/src/lib/builtins.pl @@ -185,7 +185,7 @@ fail :- '$fail'. :- meta_predicate \+(0). -\+ G :- call(G), !, false. +\+ G :- '$call'(G), !, false. \+ _. @@ -195,7 +195,7 @@ _ \= _. :- meta_predicate once(0). -once(G) :- call(G), !. +once(G) :- '$call'(G), !. repeat. @@ -216,17 +216,17 @@ G1 -> G2 :- control_entry_point((G1 -> G2)). staggered_if_then(G1, G2) :- '$get_staggered_cp'(B), - call('$call'(G1)), + '$call'(G1), '$set_cp'(B), - call('$call'(G2)). + '$call'(G2). G1 ; G2 :- control_entry_point((G1 ; G2)). :- non_counted_backtracking staggered_sc/2. -staggered_sc(G, _) :- call('$call'(G)). -staggered_sc(_, G) :- call('$call'(G)). +staggered_sc(G, _) :- '$call'(G). +staggered_sc(_, G) :- '$call'(G). !. @@ -622,10 +622,13 @@ catch(G,C,R) :- '$get_current_block'(Bb), '$call_with_default_policy'(catch(G,C,R,Bb)). +:- meta_predicate catch(0, ?, 0, ?). + :- non_counted_backtracking catch/4. + catch(G,C,R,Bb) :- '$install_new_block'(NBb), - call(G), + '$call'(G), '$call_with_default_policy'(end_block(Bb, NBb)). catch(G,C,R,Bb) :- '$reset_block'(Bb), @@ -634,6 +637,7 @@ catch(G,C,R,Bb) :- :- non_counted_backtracking end_block/2. + end_block(Bb, NBb) :- '$clean_up_block'(NBb), '$reset_block'(Bb). @@ -642,10 +646,11 @@ end_block(Bb, NBb) :- '$fail'. :- non_counted_backtracking handle_ball/3. + handle_ball(C, C, R) :- !, '$erase_ball', - call(R). + '$call'(R). handle_ball(_, _, _) :- '$unwind_stack'. @@ -685,7 +690,7 @@ findall(Template, Goal, Solutions) :- :- non_counted_backtracking '$iterate_find_all_diff'/5. '$iterate_find_all_diff'(Template, Goal, _, _, LhOffset) :- - call(Goal), + '$call'(Goal), '$copy_to_lh'(LhOffset, Template), '$fail'. '$iterate_find_all_diff'(_, _, Solutions0, Solutions1, LhOffset) :- diff --git a/src/machine/system_calls.rs b/src/machine/system_calls.rs index 61f40e0a..6e9e7a1a 100644 --- a/src/machine/system_calls.rs +++ b/src/machine/system_calls.rs @@ -627,6 +627,8 @@ impl MachineState { #[inline] pub(crate) fn install_new_block(&mut self, value: HeapCellValue) -> usize { + let value = self.store(self.deref(value)); + self.block = self.b; self.unify_fixnum(Fixnum::build_with(self.block as i64), value); @@ -4004,7 +4006,7 @@ impl Machine { #[inline(always)] pub(crate) fn inference_level(&mut self) { - let a1 = self.machine_st.registers[1]; + let a1 = self.machine_st.store(self.machine_st.deref(self.machine_st.registers[1])); let a2 = self.machine_st.store(self.machine_st.deref(self.machine_st.registers[2])); let bp = cell_as_fixnum!(a2).get_num() as usize;