From bcc4a272065bdd8b5397e0609cfc15cd5cbc4d95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Manuel=20de=20Morais=20Santos=20Costa?= Date: Tue, 26 Jan 2010 18:03:09 +0000 Subject: [PATCH] cut_succeed and cut_fail should recover pool of try_c and should do trim_trail (not that the latter really matters). --- C/absmi.c | 7 ------- H/Regs.h | 4 ---- H/amiops.h | 14 ++++++++++++++ 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/C/absmi.c b/C/absmi.c index 810b232a9..5ab978b21 100644 --- a/C/absmi.c +++ b/C/absmi.c @@ -7713,13 +7713,6 @@ Yap_absmi(int inp) setregs(); Yap_PrologMode = UserMode; if (!SREG) { -#ifdef CUT_C - /* Removes the cut functions from the stack - without executing them because we have fail - and not cuted the predicate*/ - while(POP_CHOICE_POINT(B)) - cut_c_pop(); -#endif FAIL(); } if ((CELL *) B == YREG && ASP != (CELL *) B) { diff --git a/H/Regs.h b/H/Regs.h index a957c4187..af569c988 100644 --- a/H/Regs.h +++ b/H/Regs.h @@ -722,10 +722,6 @@ EXTERN inline void restore_B(void) { #define ARG15 XREGS[15] #define ARG16 XREGS[16] -#define cut_succeed() return( ( B = B->cp_b, 1 )) -#define cut_fail() return( ( B = B->cp_b, 0 )) - - /* by default, define HBREG to be HB */ #define HBREG HB diff --git a/H/amiops.h b/H/amiops.h index e7e5e6c84..cd8744ee6 100644 --- a/H/amiops.h +++ b/H/amiops.h @@ -513,3 +513,17 @@ Yap_unify_constant(register Term a, register Term cons) #define LT_OK_IN_CMP 2 #define GT_OK_IN_CMP 4 +static inline int +do_cut(int i) { + while (POP_CHOICE_POINT(B->cp_b)) { + cut_c_pop(); + } + Yap_TrimTrail(); + B = B->cp_b; + return i; +} + +#define cut_succeed() return do_cut(TRUE) + +#define cut_fail() return do_cut(FALSE) +