From 69c0a52548517b37d3aeceebdf0ff2d9ec1f6ddf Mon Sep 17 00:00:00 2001 From: Costa Vitor Date: Fri, 26 Jun 2009 13:04:07 -0500 Subject: [PATCH] Revert "ENV may not be in scope of catch in very special cases (eg, call counter)." This reverts commit 15f9a68a35480a054d74c2a96e8047da6aa662b7. Botch! --- C/exec.c | 63 ++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 25 deletions(-) diff --git a/C/exec.c b/C/exec.c index 1f2ab4fa6..b446c6afb 100644 --- a/C/exec.c +++ b/C/exec.c @@ -1570,36 +1570,49 @@ JumpToEnv(Term t) { if (!(t = Yap_SaveTerm(t))) return FALSE; } - /* find the first choicepoint that may be a catch */ - while (B != NULL && B->cp_ap != pos) { - /* we are already doing a catch */ - if (B->cp_ap == catchpos) { - P = (yamop *)FAILCODE; - if (first_func != NULL) { - B = first_func; + do { + /* find the first choicepoint that may be a catch */ + while (B != NULL && B->cp_ap != pos) { + /* we are already doing a catch */ + if (B->cp_ap == catchpos) { + P = (yamop *)FAILCODE; + if (first_func != NULL) { + B = first_func; + } + return(FALSE); } - return(FALSE); + if (B->cp_ap == NOCODE) { + /* up to the C-code to deal with this! */ + UncaughtThrow = TRUE; + B->cp_h = H; + EX = t; + return FALSE; + } + B = B->cp_b; } - if (B->cp_ap == NOCODE) { - /* up to the C-code to deal with this! */ + /* uncaught throw */ + if (B == NULL) { UncaughtThrow = TRUE; - B->cp_h = H; - EX = t; - return FALSE; - } - B = B->cp_b; - } - /* uncaught throw */ - if (B == NULL) { - UncaughtThrow = TRUE; - B = B0; + B = B0; #if PUSH_REGS - restore_absmi_regs(&Yap_standard_regs); + restore_absmi_regs(&Yap_standard_regs); #endif - siglongjmp(Yap_RestartEnv,1); - } - /* is it a continuation? */ - env = ENV = B->cp_env; + siglongjmp(Yap_RestartEnv,1); + } + /* is it a continuation? */ + env = B->cp_env; + while (env > ENV) { + ENV = ENV_Parent(ENV); + } + /* yes, we found it ! */ + // while (env < ENV) + // env = ENV_Parent(env); + if (env == ENV) { + break; + } + /* oops, try next */ + B = B->cp_b; + } while (TRUE); /* step one environment above, otherwise we'll redo the original goal */ B->cp_cp = (yamop *)env[E_CP]; B->cp_env = (CELL *)env[E_E];